Title: [253485] trunk/Source/WebKit
Revision
253485
Author
[email protected]
Date
2019-12-13 10:35:06 -0800 (Fri, 13 Dec 2019)

Log Message

Minor WKWebView.mm code rearrangement
https://bugs.webkit.org/show_bug.cgi?id=205129

Reviewed by Tim Horton.

Throw in some more #pragma marks and move some functions around, with the goal of
having the implementation order mostly follow header order, and grouping related functions.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _pageForTesting]):
(-[WKWebView _page]):
(-[WKWebView urlSchemeHandlerForURLScheme:]):
(+[WKWebView handlesURLScheme:]):
(-[WKWebView _resolutionForShareSheetImmediateCompletionForTesting]):
(-[WKWebView createPDFWithConfiguration:completionHandler:]):
(-[WKWebView createWebArchiveDataWithCompletionHandler:]):
(toFindOptions):
(-[WKWebView findString:withConfiguration:completionHandler:]):
(-[WKWebView setMediaType:]):
(-[WKWebView mediaType]):
(-[WKWebView layoutSubviews]):
(-[WKWebView scrollView]):
(-[WKWebView _isShowingVideoPictureInPicture]):
(-[WKWebView _mayAutomaticallyShowVideoPictureInPicture]):
(-[WKWebView _incrementFocusPreservationCount]):
(-[WKWebView _decrementFocusPreservationCount]):
(-[WKWebView _resetFocusPreservationCount]):
(-[WKWebView _isRetainingActiveFocusedState]):
(-[WKWebView _effectiveAppearanceIsDark]):
(-[WKWebView _effectiveUserInterfaceLevelIsElevated]):
(-[WKWebView _shouldAvoidResizingWhenInputViewBoundsChange]):
(-[WKWebView _dragInteractionPolicy]):
(-[WKWebView _setDragInteractionPolicy:]):
(-[WKWebView _populateArchivedSubviews:]):
(-[WKWebView _isBackground]):
(-[WKWebView _setShouldSuppressFirstResponderChanges:]):
(-[WKWebView _retainActiveFocusedState]):
(-[WKWebView _becomeFirstResponderWithSelectionMovingForward:completionHandler:]):
(-[WKWebView _snapshotLayerContentsForBackForwardListItem:]):
(-[WKWebView _dataDetectionResults]):
(-[WKWebView _accessibilityRetrieveSpeakSelectionContent]):
(-[WKWebView _accessibilityDidGetSpeakSelectionContent:]):
(-[WKWebView _viewportSizeForCSSViewportUnits]):
(-[WKWebView _setViewportSizeForCSSViewportUnits:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm: Unified sources build fix (seen while doing other stuff).

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (253484 => 253485)


--- trunk/Source/WebKit/ChangeLog	2019-12-13 18:13:21 UTC (rev 253484)
+++ trunk/Source/WebKit/ChangeLog	2019-12-13 18:35:06 UTC (rev 253485)
@@ -287,6 +287,55 @@
 
 2019-12-12  Simon Fraser  <[email protected]>
 
+        Minor WKWebView.mm code rearrangement
+        https://bugs.webkit.org/show_bug.cgi?id=205129
+
+        Reviewed by Tim Horton.
+
+        Throw in some more #pragma marks and move some functions around, with the goal of
+        having the implementation order mostly follow header order, and grouping related functions.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _pageForTesting]):
+        (-[WKWebView _page]):
+        (-[WKWebView urlSchemeHandlerForURLScheme:]):
+        (+[WKWebView handlesURLScheme:]):
+        (-[WKWebView _resolutionForShareSheetImmediateCompletionForTesting]):
+        (-[WKWebView createPDFWithConfiguration:completionHandler:]):
+        (-[WKWebView createWebArchiveDataWithCompletionHandler:]):
+        (toFindOptions):
+        (-[WKWebView findString:withConfiguration:completionHandler:]):
+        (-[WKWebView setMediaType:]):
+        (-[WKWebView mediaType]):
+        (-[WKWebView layoutSubviews]):
+        (-[WKWebView scrollView]):
+        (-[WKWebView _isShowingVideoPictureInPicture]):
+        (-[WKWebView _mayAutomaticallyShowVideoPictureInPicture]):
+        (-[WKWebView _incrementFocusPreservationCount]):
+        (-[WKWebView _decrementFocusPreservationCount]):
+        (-[WKWebView _resetFocusPreservationCount]):
+        (-[WKWebView _isRetainingActiveFocusedState]):
+        (-[WKWebView _effectiveAppearanceIsDark]):
+        (-[WKWebView _effectiveUserInterfaceLevelIsElevated]):
+        (-[WKWebView _shouldAvoidResizingWhenInputViewBoundsChange]):
+        (-[WKWebView _dragInteractionPolicy]):
+        (-[WKWebView _setDragInteractionPolicy:]):
+        (-[WKWebView _populateArchivedSubviews:]):
+        (-[WKWebView _isBackground]):
+        (-[WKWebView _setShouldSuppressFirstResponderChanges:]):
+        (-[WKWebView _retainActiveFocusedState]):
+        (-[WKWebView _becomeFirstResponderWithSelectionMovingForward:completionHandler:]):
+        (-[WKWebView _snapshotLayerContentsForBackForwardListItem:]):
+        (-[WKWebView _dataDetectionResults]):
+        (-[WKWebView _accessibilityRetrieveSpeakSelectionContent]):
+        (-[WKWebView _accessibilityDidGetSpeakSelectionContent:]):
+        (-[WKWebView _viewportSizeForCSSViewportUnits]):
+        (-[WKWebView _setViewportSizeForCSSViewportUnits:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm: Unified sources build fix (seen while doing other stuff).
+
+2019-12-12  Simon Fraser  <[email protected]>
+
         Move WKWebView code related to testing to new files, with new private "for testing" headers.
         https://bugs.webkit.org/show_bug.cgi?id=205021
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (253484 => 253485)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-12-13 18:13:21 UTC (rev 253484)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-12-13 18:35:06 UTC (rev 253485)
@@ -421,30 +421,6 @@
 ALLOW_DEPRECATED_DECLARATIONS_END
 }
 
-- (BOOL)_isShowingVideoPictureInPicture
-{
-#if !HAVE(AVKIT)
-    return false;
-#else
-    if (!_page || !_page->videoFullscreenManager())
-        return false;
-
-    return _page->videoFullscreenManager()->hasMode(WebCore::HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
-#endif
-}
-
-- (BOOL)_mayAutomaticallyShowVideoPictureInPicture
-{
-#if !HAVE(AVKIT)
-    return false;
-#else
-    if (!_page || !_page->videoFullscreenManager())
-        return false;
-
-    return _page->videoFullscreenManager()->mayAutomaticallyShowVideoPictureInPicture();
-#endif
-}
-
 static bool shouldAllowPictureInPictureMediaPlayback()
 {
     static bool shouldAllowPictureInPictureMediaPlayback = dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_9_0;
@@ -457,45 +433,6 @@
     return shouldAllowSettingAnyXHRHeaderFromFileURLs;
 }
 
-- (void)_incrementFocusPreservationCount
-{
-    ++_focusPreservationCount;
-}
-
-- (void)_decrementFocusPreservationCount
-{
-    if (_focusPreservationCount)
-        --_focusPreservationCount;
-}
-
-- (void)_resetFocusPreservationCount
-{
-    _focusPreservationCount = 0;
-}
-
-- (BOOL)_isRetainingActiveFocusedState
-{
-    // Focus preservation count fulfills the same role as active focus state count.
-    // However, unlike active focus state, it may be reset to 0 without impacting the
-    // behavior of -_retainActiveFocusedState, and it's harmless to invoke
-    // -_decrementFocusPreservationCount after resetting the count to 0.
-    return _focusPreservationCount || _activeFocusedStateRetainCount;
-}
-
-- (BOOL)_effectiveAppearanceIsDark
-{
-    return self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark;
-}
-
-- (BOOL)_effectiveUserInterfaceLevelIsElevated
-{
-#if HAVE(OS_DARK_MODE_SUPPORT) && !PLATFORM(WATCHOS)
-    return self.traitCollection.userInterfaceLevel == UIUserInterfaceLevelElevated;
-#else
-    return NO;
-#endif
-}
-
 #endif // PLATFORM(IOS_FAMILY)
 
 static bool shouldRequireUserGestureToLoadVideo()
@@ -917,6 +854,8 @@
     return [super valueForUndefinedKey:key];
 }
 
+#pragma mark - API
+
 - (WKWebViewConfiguration *)configuration
 {
     return [[_configuration copy] autorelease];
@@ -1246,16 +1185,6 @@
     _page->setCustomUserAgent(customUserAgent);
 }
 
-- (WKPageRef)_pageForTesting
-{
-    return toAPI(_page.get());
-}
-
-- (WebKit::WebPageProxy *)_page
-{
-    return _page.get();
-}
-
 - (BOOL)allowsLinkPreview
 {
 #if PLATFORM(MAC)
@@ -1286,20 +1215,6 @@
 #endif // PLATFORM(IOS_FAMILY)
 }
 
-- (CGSize)_viewportSizeForCSSViewportUnits
-{
-    return _page->viewportSizeForCSSViewportUnits();
-}
-
-- (void)_setViewportSizeForCSSViewportUnits:(CGSize)viewportSize
-{
-    auto viewportSizeForViewportUnits = WebCore::IntSize(viewportSize);
-    if (viewportSizeForViewportUnits.isEmpty())
-        [NSException raise:NSInvalidArgumentException format:@"Viewport size should not be empty"];
-
-    _page->setViewportSizeForCSSViewportUnits(viewportSizeForViewportUnits);
-}
-
 static NSTextAlignment nsTextAlignment(WebKit::TextAlignment alignment)
 {
     switch (alignment) {
@@ -1475,48 +1390,114 @@
 
 #endif // ENABLE(ATTACHMENT_ELEMENT)
 
-#pragma mark iOS-specific methods
+#pragma mark - macOS/iOS implementation methods
 
-#if PLATFORM(IOS_FAMILY)
+- (WKPageRef)_pageForTesting
+{
+    return toAPI(_page.get());
+}
 
-- (BOOL)_shouldAvoidResizingWhenInputViewBoundsChange
+- (WebKit::WebPageProxy *)_page
 {
-    return [_contentView _shouldAvoidResizingWhenInputViewBoundsChange];
+    return _page.get();
 }
 
-- (_WKDragInteractionPolicy)_dragInteractionPolicy
+- (id <WKURLSchemeHandler>)urlSchemeHandlerForURLScheme:(NSString *)urlScheme
 {
-    return _dragInteractionPolicy;
+    auto* handler = static_cast<WebKit::WebURLSchemeHandlerCocoa*>(_page->urlSchemeHandlerForScheme(urlScheme));
+    return handler ? handler->apiHandler() : nil;
 }
 
-- (void)_setDragInteractionPolicy:(_WKDragInteractionPolicy)policy
++ (BOOL)handlesURLScheme:(NSString *)urlScheme
 {
-    if (_dragInteractionPolicy == policy)
+    return WebCore::LegacySchemeRegistry::isBuiltinScheme(urlScheme);
+}
+
+- (Optional<BOOL>)_resolutionForShareSheetImmediateCompletionForTesting
+{
+    return _resolutionForShareSheetImmediateCompletionForTesting;
+}
+
+- (void)createPDFWithConfiguration:(WKPDFConfiguration *)pdfConfiguration completionHandler:(void (^)(NSData *pdfDocumentData, NSError *error))completionHandler
+{
+    WebCore::FrameIdentifier frameID;
+    if (auto mainFrame = _page->mainFrame())
+        frameID = mainFrame->frameID();
+    else {
+        completionHandler(nil, createNSError(WKErrorUnknown).get());
         return;
+    }
 
-    _dragInteractionPolicy = policy;
-#if ENABLE(DRAG_SUPPORT)
-    [_contentView _didChangeDragInteractionPolicy];
-#endif
+    Optional<WebCore::FloatRect> floatRect;
+    if (pdfConfiguration && !CGRectIsNull(pdfConfiguration.rect))
+        floatRect = WebCore::FloatRect(pdfConfiguration.rect);
+
+    auto handler = makeBlockPtr(completionHandler);
+    _page->drawToPDF(frameID, floatRect, [retainedSelf = retainPtr(self), handler = WTFMove(handler)](const IPC::DataReference& pdfData, WebKit::CallbackBase::Error error) {
+        if (error != WebKit::CallbackBase::Error::None) {
+            handler(nil, createNSError(WKErrorUnknown).get());
+            return;
+        }
+
+        auto data = "" pdfData.data(), pdfData.size()));
+        handler((NSData *)data.get(), nil);
+    });
 }
 
-- (void)_populateArchivedSubviews:(NSMutableSet *)encodedViews
+- (void)createWebArchiveDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler
 {
-    [super _populateArchivedSubviews:encodedViews];
+    auto handler = adoptNS([completionHandler copy]);
 
-    if (_scrollView)
-        [encodedViews removeObject:_scrollView.get()];
-    if (_customContentFixedOverlayView)
-        [encodedViews removeObject:_customContentFixedOverlayView.get()];
+    _page->getWebArchiveOfFrame(_page->mainFrame(), [handler](API::Data* data, WebKit::CallbackBase::Error error) {
+        void (^completionHandlerBlock)(NSData *, NSError *) = (void (^)(NSData *, NSError *))handler.get();
+        if (error != WebKit::CallbackBase::Error::None) {
+            // FIXME: Pipe a proper error in from the WebPageProxy.
+            completionHandlerBlock(nil, [NSError errorWithDomain:WKErrorDomain code:static_cast<int>(error) userInfo:nil]);
+        } else
+            completionHandlerBlock(wrapper(*data), nil);
+    });
 }
 
-- (BOOL)_isBackground
+inline WebKit::FindOptions toFindOptions(WKFindConfiguration *configuration)
 {
-    if (![self usesStandardContentView] && [_customContentView respondsToSelector:@selector(web_isBackground)])
-        return [_customContentView web_isBackground];
-    return [_contentView isBackground];
+    unsigned findOptions = 0;
+
+    if (!configuration.caseSensitive)
+        findOptions |= WebKit::FindOptionsCaseInsensitive;
+    if (configuration.backwards)
+        findOptions |= WebKit::FindOptionsBackwards;
+    if (configuration.wraps)
+        findOptions |= WebKit::FindOptionsWrapAround;
+
+    return static_cast<WebKit::FindOptions>(findOptions);
 }
 
+- (void)findString:(NSString *)string withConfiguration:(WKFindConfiguration *)configuration completionHandler:(void (^)(WKFindResult *result))completionHandler
+{
+    if (!string.length) {
+        completionHandler([[[WKFindResult alloc] _initWithMatchFound:NO] autorelease]);
+        return;
+    }
+
+    _page->findString(string, toFindOptions(configuration), 1, [handler = makeBlockPtr(completionHandler)](bool found, WebKit::CallbackBase::Error error) {
+        handler([[[WKFindResult alloc] _initWithMatchFound:(error == WebKit::CallbackBase::Error::None && found)] autorelease]);
+    });
+}
+
+- (void)setMediaType:(NSString *)mediaStyle
+{
+    _page->setOverriddenMediaType(mediaStyle);
+}
+
+- (NSString *)mediaType
+{
+    return _page->overriddenMediaType().isNull() ? nil : (NSString *)_page->overriddenMediaType();
+}
+
+#if PLATFORM(IOS_FAMILY)
+
+#pragma mark - UIView overrides
+
 - (void)setFrame:(CGRect)frame
 {
     CGRect oldFrame = self.frame;
@@ -1548,6 +1529,109 @@
     return _scrollView.get();
 }
 
+#pragma mark - iOS implementation methods
+
+- (BOOL)_isShowingVideoPictureInPicture
+{
+#if !HAVE(AVKIT)
+    return false;
+#else
+    if (!_page || !_page->videoFullscreenManager())
+        return false;
+
+    return _page->videoFullscreenManager()->hasMode(WebCore::HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
+#endif
+}
+
+- (BOOL)_mayAutomaticallyShowVideoPictureInPicture
+{
+#if !HAVE(AVKIT)
+    return false;
+#else
+    if (!_page || !_page->videoFullscreenManager())
+        return false;
+
+    return _page->videoFullscreenManager()->mayAutomaticallyShowVideoPictureInPicture();
+#endif
+}
+
+- (void)_incrementFocusPreservationCount
+{
+    ++_focusPreservationCount;
+}
+
+- (void)_decrementFocusPreservationCount
+{
+    if (_focusPreservationCount)
+        --_focusPreservationCount;
+}
+
+- (void)_resetFocusPreservationCount
+{
+    _focusPreservationCount = 0;
+}
+
+- (BOOL)_isRetainingActiveFocusedState
+{
+    // Focus preservation count fulfills the same role as active focus state count.
+    // However, unlike active focus state, it may be reset to 0 without impacting the
+    // behavior of -_retainActiveFocusedState, and it's harmless to invoke
+    // -_decrementFocusPreservationCount after resetting the count to 0.
+    return _focusPreservationCount || _activeFocusedStateRetainCount;
+}
+
+- (BOOL)_effectiveAppearanceIsDark
+{
+    return self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark;
+}
+
+- (BOOL)_effectiveUserInterfaceLevelIsElevated
+{
+#if HAVE(OS_DARK_MODE_SUPPORT) && !PLATFORM(WATCHOS)
+    return self.traitCollection.userInterfaceLevel == UIUserInterfaceLevelElevated;
+#else
+    return NO;
+#endif
+}
+
+- (BOOL)_shouldAvoidResizingWhenInputViewBoundsChange
+{
+    return [_contentView _shouldAvoidResizingWhenInputViewBoundsChange];
+}
+
+- (_WKDragInteractionPolicy)_dragInteractionPolicy
+{
+    return _dragInteractionPolicy;
+}
+
+- (void)_setDragInteractionPolicy:(_WKDragInteractionPolicy)policy
+{
+    if (_dragInteractionPolicy == policy)
+        return;
+
+    _dragInteractionPolicy = policy;
+#if ENABLE(DRAG_SUPPORT)
+    [_contentView _didChangeDragInteractionPolicy];
+#endif
+}
+
+- (void)_populateArchivedSubviews:(NSMutableSet *)encodedViews
+{
+    [super _populateArchivedSubviews:encodedViews];
+
+    if (_scrollView)
+        [encodedViews removeObject:_scrollView.get()];
+    if (_customContentFixedOverlayView)
+        [encodedViews removeObject:_customContentFixedOverlayView.get()];
+}
+
+- (BOOL)_isBackground
+{
+    if (![self usesStandardContentView] && [_customContentView respondsToSelector:@selector(web_isBackground)])
+        return [_customContentView web_isBackground];
+    return [_contentView isBackground];
+}
+
 ALLOW_DEPRECATED_DECLARATIONS_BEGIN
 - (WKBrowsingContextController *)browsingContextController
 {
@@ -2717,7 +2801,7 @@
     return [_configuration _editableImagesEnabled];
 }
 
-#pragma mark - UIScrollViewDelegate
+#pragma mark UIScrollViewDelegate
 
 - (BOOL)usesStandardContentView
 {
@@ -2905,6 +2989,8 @@
     [self _scheduleVisibleContentRectUpdateAfterScrollInView:scrollView];
 }
 
+#pragma mark end UIScrollViewDelegate
+
 - (UIView *)_enclosingViewForExposedRectComputation
 {
     return [self _scroller];
@@ -3634,7 +3720,7 @@
 
 #endif // PLATFORM(IOS_FAMILY)
 
-#pragma mark OS X-specific methods
+#pragma mark - NSView overrides
 
 #if PLATFORM(MAC)
 
@@ -3685,6 +3771,8 @@
     _impl->setFrameSize(NSSizeToCGSize(size));
 }
 
+#pragma mark - macOS implementation
+
 - (void)_web_grantDOMPasteAccess
 {
     _impl->handleDOMPasteRequestWithResult(WebCore::DOMPasteAccessResponse::GrantedForGesture);
@@ -3710,6 +3798,8 @@
     [super renewGState];
 }
 
+#pragma mark - macOS IBAction/NSResponder
+
 #define WEBCORE_COMMAND(command) - (void)command:(id)sender { _impl->executeEditCommandForSelector(_cmd); }
 
 WEBCORE_COMMAND(alignCenter)
@@ -4690,6 +4780,8 @@
 
 #endif // PLATFORM(MAC)
 
+#pragma mark - touchBar methods
+
 #if HAVE(TOUCH_BAR)
 
 @dynamic touchBar;
@@ -4722,102 +4814,14 @@
 
 #endif // HAVE(TOUCH_BAR)
 
-- (id <WKURLSchemeHandler>)urlSchemeHandlerForURLScheme:(NSString *)urlScheme
-{
-    auto* handler = static_cast<WebKit::WebURLSchemeHandlerCocoa*>(_page->urlSchemeHandlerForScheme(urlScheme));
-    return handler ? handler->apiHandler() : nil;
-}
+@end
 
-+ (BOOL)handlesURLScheme:(NSString *)urlScheme
-{
-    return WebCore::LegacySchemeRegistry::isBuiltinScheme(urlScheme);
-}
+#pragma mark - WKWebView (WKPrivate)
 
-- (Optional<BOOL>)_resolutionForShareSheetImmediateCompletionForTesting
-{
-    return _resolutionForShareSheetImmediateCompletionForTesting;
-}
+@implementation WKWebView (WKPrivate)
 
-- (void)createPDFWithConfiguration:(WKPDFConfiguration *)pdfConfiguration completionHandler:(void (^)(NSData *pdfDocumentData, NSError *error))completionHandler
-{
-    WebCore::FrameIdentifier frameID;
-    if (auto mainFrame = _page->mainFrame())
-        frameID = mainFrame->frameID();
-    else {
-        completionHandler(nil, createNSError(WKErrorUnknown).get());
-        return;
-    }
+#pragma mark - macOS WKPrivate
 
-    Optional<WebCore::FloatRect> floatRect;
-    if (pdfConfiguration && !CGRectIsNull(pdfConfiguration.rect))
-        floatRect = WebCore::FloatRect(pdfConfiguration.rect);
-
-    auto handler = makeBlockPtr(completionHandler);
-    _page->drawToPDF(frameID, floatRect, [retainedSelf = retainPtr(self), handler = WTFMove(handler)](const IPC::DataReference& pdfData, WebKit::CallbackBase::Error error) {
-        if (error != WebKit::CallbackBase::Error::None) {
-            handler(nil, createNSError(WKErrorUnknown).get());
-            return;
-        }
-
-        auto data = "" pdfData.data(), pdfData.size()));
-        handler((NSData *)data.get(), nil);
-    });
-}
-
-- (void)createWebArchiveDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler
-{
-    auto handler = adoptNS([completionHandler copy]);
-
-    _page->getWebArchiveOfFrame(_page->mainFrame(), [handler](API::Data* data, WebKit::CallbackBase::Error error) {
-        void (^completionHandlerBlock)(NSData *, NSError *) = (void (^)(NSData *, NSError *))handler.get();
-        if (error != WebKit::CallbackBase::Error::None) {
-            // FIXME: Pipe a proper error in from the WebPageProxy.
-            completionHandlerBlock(nil, [NSError errorWithDomain:WKErrorDomain code:static_cast<int>(error) userInfo:nil]);
-        } else
-            completionHandlerBlock(wrapper(*data), nil);
-    });
-}
-
-inline WebKit::FindOptions toFindOptions(WKFindConfiguration *configuration)
-{
-    unsigned findOptions = 0;
-
-    if (!configuration.caseSensitive)
-        findOptions |= WebKit::FindOptionsCaseInsensitive;
-    if (configuration.backwards)
-        findOptions |= WebKit::FindOptionsBackwards;
-    if (configuration.wraps)
-        findOptions |= WebKit::FindOptionsWrapAround;
-
-    return static_cast<WebKit::FindOptions>(findOptions);
-}
-
-- (void)findString:(NSString *)string withConfiguration:(WKFindConfiguration *)configuration completionHandler:(void (^)(WKFindResult *result))completionHandler
-{
-    if (!string.length) {
-        completionHandler([[[WKFindResult alloc] _initWithMatchFound:NO] autorelease]);
-        return;
-    }
-
-    _page->findString(string, toFindOptions(configuration), 1, [handler = makeBlockPtr(completionHandler)](bool found, WebKit::CallbackBase::Error error) {
-        handler([[[WKFindResult alloc] _initWithMatchFound:(error == WebKit::CallbackBase::Error::None && found)] autorelease]);
-    });
-}
-
-- (void)setMediaType:(NSString *)mediaStyle
-{
-    _page->setOverriddenMediaType(mediaStyle);
-}
-
-- (NSString *)mediaType
-{
-    return _page->overriddenMediaType().isNull() ? nil : (NSString *)_page->overriddenMediaType();
-}
-
-@end
-
-@implementation WKWebView (WKPrivate)
-
 #if PLATFORM(MAC)
 
 #define WEBCORE_PRIVATE_COMMAND(command) - (void)_##command:(id)sender { _page->executeEditCommand(#command ## _s); }
@@ -4984,8 +4988,15 @@
     return _impl->totalHeightOfBanners();
 }
 
+- (void)_setShouldSuppressFirstResponderChanges:(BOOL)shouldSuppress
+{
+    _impl->setShouldSuppressFirstResponderChanges(shouldSuppress);
+}
+
 #endif // PLATFORM(MAC)
 
+#pragma mark - iOS WKPrivate
+
 #if PLATFORM(IOS_FAMILY)
 
 FOR_EACH_PRIVATE_WKCONTENTVIEW_ACTION(FORWARD_ACTION_TO_WKCONTENTVIEW)
@@ -5097,8 +5108,80 @@
     return self._currentContentView.isFirstResponder;
 }
 
+- (void (^)(void))_retainActiveFocusedState
+{
+    ++_activeFocusedStateRetainCount;
+
+    // FIXME: Use something like CompletionHandlerCallChecker to ensure that the returned block is called before it's released.
+    return [[[self] {
+        --_activeFocusedStateRetainCount;
+    } copy] autorelease];
+}
+
+- (void)_becomeFirstResponderWithSelectionMovingForward:(BOOL)selectingForward completionHandler:(void (^)(BOOL didBecomeFirstResponder))completionHandler
+{
+    typeof(completionHandler) completionHandlerCopy = nil;
+    if (completionHandler)
+        completionHandlerCopy = Block_copy(completionHandler);
+
+    [_contentView _becomeFirstResponderWithSelectionMovingForward:selectingForward completionHandler:[completionHandlerCopy](BOOL didBecomeFirstResponder) {
+        if (!completionHandlerCopy)
+            return;
+
+        completionHandlerCopy(didBecomeFirstResponder);
+        Block_release(completionHandlerCopy);
+    }];
+}
+
+- (id)_snapshotLayerContentsForBackForwardListItem:(WKBackForwardListItem *)item
+{
+    if (_page->backForwardList().currentItem() == &item._item)
+        _page->recordNavigationSnapshot(*_page->backForwardList().currentItem());
+
+    if (auto* viewSnapshot = item._item.snapshot())
+        return viewSnapshot->asLayerContents();
+
+    return nil;
+}
+
+- (NSArray *)_dataDetectionResults
+{
+#if ENABLE(DATA_DETECTION)
+    return [_contentView _dataDetectionResults];
+#else
+    return nil;
+#endif
+}
+
+- (void)_accessibilityRetrieveSpeakSelectionContent
+{
+    [_contentView accessibilityRetrieveSpeakSelectionContent];
+}
+
+// This method is for subclasses to override.
+// Currently it's only in TestRunnerWKWebView.
+- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content
+{
+}
+
 #endif // PLATFORM(IOS_FAMILY)
 
+#pragma mark - macOS/iOS WKPrivate
+
+- (CGSize)_viewportSizeForCSSViewportUnits
+{
+    return _page->viewportSizeForCSSViewportUnits();
+}
+
+- (void)_setViewportSizeForCSSViewportUnits:(CGSize)viewportSize
+{
+    auto viewportSizeForViewportUnits = WebCore::IntSize(viewportSize);
+    if (viewportSizeForViewportUnits.isEmpty())
+        [NSException raise:NSInvalidArgumentException format:@"Viewport size should not be empty"];
+
+    _page->setViewportSizeForCSSViewportUnits(viewportSizeForViewportUnits);
+}
+
 - (_WKInspector *)_inspector
 {
     if (auto* inspector = _page->inspector())
@@ -5564,70 +5647,8 @@
     [self createPDFWithConfiguration:pdfConfiguration completionHandler:completionHandler];
 }
 
-#if PLATFORM(MAC)
-- (void)_setShouldSuppressFirstResponderChanges:(BOOL)shouldSuppress
-{
-    _impl->setShouldSuppressFirstResponderChanges(shouldSuppress);
-}
-#endif
-
 #if PLATFORM(IOS_FAMILY)
-- (void (^)(void))_retainActiveFocusedState
-{
-    ++_activeFocusedStateRetainCount;
 
-    // FIXME: Use something like CompletionHandlerCallChecker to ensure that the returned block is called before it's released.
-    return [[[self] {
-        --_activeFocusedStateRetainCount;
-    } copy] autorelease];
-}
-
-- (void)_becomeFirstResponderWithSelectionMovingForward:(BOOL)selectingForward completionHandler:(void (^)(BOOL didBecomeFirstResponder))completionHandler
-{
-    typeof(completionHandler) completionHandlerCopy = nil;
-    if (completionHandler)
-        completionHandlerCopy = Block_copy(completionHandler);
-
-    [_contentView _becomeFirstResponderWithSelectionMovingForward:selectingForward completionHandler:[completionHandlerCopy](BOOL didBecomeFirstResponder) {
-        if (!completionHandlerCopy)
-            return;
-
-        completionHandlerCopy(didBecomeFirstResponder);
-        Block_release(completionHandlerCopy);
-    }];
-}
-
-- (id)_snapshotLayerContentsForBackForwardListItem:(WKBackForwardListItem *)item
-{
-    if (_page->backForwardList().currentItem() == &item._item)
-        _page->recordNavigationSnapshot(*_page->backForwardList().currentItem());
-
-    if (auto* viewSnapshot = item._item.snapshot())
-        return viewSnapshot->asLayerContents();
-
-    return nil;
-}
-
-- (NSArray *)_dataDetectionResults
-{
-#if ENABLE(DATA_DETECTION)
-    return [_contentView _dataDetectionResults];
-#else
-    return nil;
-#endif
-}
-
-- (void)_accessibilityRetrieveSpeakSelectionContent
-{
-    [_contentView accessibilityRetrieveSpeakSelectionContent];
-}
-
-// This method is for subclasses to override.
-// Currently it's only in TestRunnerWKWebView.
-- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content
-{
-}
-
 - (UITextInputAssistantItem *)inputAssistantItem
 {
     return [_contentView inputAssistantItemForWebView];
@@ -6505,7 +6526,7 @@
 }
 #endif
 
-#pragma mark iOS-specific methods
+#pragma mark - iOS WKPrivate
 
 #if PLATFORM(IOS_FAMILY)
 
@@ -7033,7 +7054,7 @@
 
 #else // #if PLATFORM(IOS_FAMILY)
 
-#pragma mark - OS X-specific methods
+#pragma mark - macOS WKPrivate
 
 - (BOOL)_drawsBackground
 {

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (253484 => 253485)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2019-12-13 18:13:21 UTC (rev 253484)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2019-12-13 18:35:06 UTC (rev 253485)
@@ -140,6 +140,7 @@
 
 @property (nonatomic, readonly) NSURL *_unreachableURL;
 @property (nonatomic, readonly) NSURL *_mainFrameURL WK_API_AVAILABLE(macos(10.15), ios(13.0));
+@property (nonatomic, readonly) NSURL *_resourceDirectoryURL WK_API_AVAILABLE(macos(10.15), ios(13.0));
 
 - (void)_loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL;
 - (WKNavigation *)_loadData:(NSData *)data MIMEType:(NSString *)MIMEType characterEncodingName:(NSString *)characterEncodingName baseURL:(NSURL *)baseURL userData:(id)userData WK_API_AVAILABLE(macos(10.12), ios(10.0));
@@ -149,12 +150,10 @@
 @property (nonatomic, readonly) NSURL *_committedURL;
 @property (nonatomic, readonly) NSString *_MIMEType;
 @property (nonatomic, readonly) NSString *_userAgent WK_API_AVAILABLE(macos(10.11), ios(9.0));
-
-@property (nonatomic, readonly, getter=_isPlayingAudio) BOOL _playingAudio WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
-
 @property (copy, setter=_setApplicationNameForUserAgent:) NSString *_applicationNameForUserAgent;
 @property (copy, setter=_setCustomUserAgent:) NSString *_customUserAgent;
 
+@property (nonatomic, readonly, getter=_isPlayingAudio) BOOL _playingAudio WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
 @property (nonatomic, setter=_setUserContentExtensionsEnabled:) BOOL _userContentExtensionsEnabled WK_API_AVAILABLE(macos(10.11), ios(9.0));
 
 @property (nonatomic, readonly) pid_t _webProcessIdentifier;
@@ -185,8 +184,6 @@
 
 @property (nonatomic, readonly, getter=_isShowingNavigationGestureSnapshot) BOOL _showingNavigationGestureSnapshot;
 
-@property (nonatomic, readonly) NSURL *_resourceDirectoryURL WK_API_AVAILABLE(macos(10.15), ios(13.0));
-
 - (void)_close;
 
 - (void)_updateWebsitePolicies:(_WKWebsitePolicies *)websitePolicies WK_API_AVAILABLE(macos(10.13), ios(11.0));

Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm (253484 => 253485)


--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm	2019-12-13 18:13:21 UTC (rev 253484)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm	2019-12-13 18:35:06 UTC (rev 253485)
@@ -34,6 +34,7 @@
 #import "RedirectSOAuthorizationSession.h"
 #import "SubFrameSOAuthorizationSession.h"
 #import "WKSOAuthorizationDelegate.h"
+#import "WebPageProxy.h"
 #import <WebCore/ResourceRequest.h>
 #import <pal/cocoa/AppSSOSoftLink.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to