⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 295360 in webkit


Ignore:
Timestamp:
Jun 7, 2022, 12:52:13 PM (4 years ago)
Author:
Wenson Hsieh
Message:

Upstream WebKit support for Stage Manager on iPadOS
​https://bugs.webkit.org/show_bug.cgi?id=241372
rdar://94540740

Reviewed by Tim Horton.

Upstream support for viewport and snapshotting behaviors that are specific to window resizing on
iPad, when Stage Manager is enabled. In particular, this merges the existing MULTITASKING_MODE
and MAC_CATALYST_LIVE_RESIZE feature flags into a single UIKIT_RESIZABLE_WINDOWS flag, which is
used to guard both snapshotting and viewport code.

  • Source/WTF/wtf/PlatformHave.h:
  • Source/WebKit/Platform/spi/ios/UIKitSPI.h:
  • Source/WebKit/Shared/WebPageCreationParameters.cpp:

(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):

  • Source/WebKit/Shared/WebPageCreationParameters.h:
  • Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView dealloc]):

  • Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:
  • Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h:
  • Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:

(-[WKWebView setFrame:]):
(-[WKWebView setBounds:]):
(-[WKWebView _registerForNotifications]):
(-[WKWebView _processWillSwapOrDidExit]):
(-[WKWebView didMoveToWindow]):
(-[WKWebView _isWindowResizingEnabled]):
(-[WKWebView _enhancedWindowingToggled:]):
(-[WKWebView _beginAnimatedResizeWithUpdates:]):
(-[WKWebView _multitaskingModeDidChange:]): Deleted.

  • Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm:

(-[WKWebView _hasResizeAssertion]):

  • Source/WebKit/UIProcess/PageClient.h:

(WebKit::PageClient::hasResizableWindows const):
(WebKit::PageClient::isInMultitaskingMode const): Deleted.

  • Source/WebKit/UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::creationParameters):
(WebKit::WebPageProxy::setIsWindowResizingEnabled):
(WebKit::WebPageProxy::setIsInMultitaskingMode): Deleted.

  • Source/WebKit/UIProcess/WebPageProxy.h:
  • Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
  • Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::hasResizableWindows const):
(WebKit::PageClientImpl::isInMultitaskingMode const): Deleted.

  • Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::isDesktopClassBrowsingRecommended const):

  • Source/WebKit/WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::didCommitLoad):
(WebKit::WebPage::setIsWindowResizingEnabled):
(WebKit::WebPage::setIsInMultitaskingMode): Deleted.

  • Source/WebKit/WebProcess/WebPage/WebPage.h:
  • Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
  • Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::dynamicViewportSizeUpdate):
(WebKit::WebPage::shouldEnableViewportBehaviorsForResizableWindows const):
(WebKit::WebPage::usesMultitaskingModeViewportBehaviors const): Deleted.

Canonical link: ​https://commits.webkit.org/251369@main

Location:
trunk/Source
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/wtf/PlatformHave.h

    r295357 r295360  
    12151215#define HAVE_VK_IMAGE_TRANSLATION_SUPPORT 1
    12161216#endif
     1217
     1218#if !defined(HAVE_UIKIT_RESIZABLE_WINDOWS) && PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 160000
     1219#define HAVE_UIKIT_RESIZABLE_WINDOWS 1
     1220#endif
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r294641 r295360  
    9090#import <UIKit/UIWebTiledView.h>
    9191#import <UIKit/UIWebTouchEventsGestureRecognizer.h>
     92#import <UIKit/UIWindowScene_Private.h>
    9293#import <UIKit/UIWindow_Private.h>
    9394#import <UIKit/_UIApplicationRotationFollowing.h>
    … …  
    148149#if HAVE(UIKIT_HOVER_EVENT_PROTOCOL)
    149150#import <UIKit/UIHoverEvent_RequiresApproval.h>
     151#endif
     152
     153#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     154#import <UIKit/UIWindowScene_RequiresApproval.h>
     155#import <UIKit/_UIInvalidatable.h>
    150156#endif
    151157
    … …  
    13811387#endif
    13821388
     1389#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     1390
     1391@protocol _UIInvalidatable <NSObject>
     1392- (void)_invalidate;
     1393@end
     1394
     1395@interface UIWindowScene ()
     1396- (id<_UIInvalidatable>)_holdLiveResizeSnapshotForReason:(NSString *)reason;
     1397@property (nonatomic, readonly) BOOL _enhancedWindowingEnabled;
     1398@end
     1399
     1400#endif // HAVE(UIKIT_RESIZABLE_WINDOWS)
     1401
    13831402#endif // USE(APPLE_INTERNAL_SDK)
    13841403
    … …  
    15681587#endif
    15691588
    1570 #if HAVE(MAC_CATALYST_LIVE_RESIZE)
    1571 
    1572 #if __has_include(<UIKit/_UIInvalidatable.h>)
    1573 #include <UIKit/_UIInvalidatable.h>
    1574 #else
    1575 @protocol _UIInvalidatable <NSObject>
    1576 - (void)_invalidate;
    1577 @end
    1578 #endif
    1579 
    1580 @interface UIWindowScene (Staging_86494115)
    1581 - (id<_UIInvalidatable>)_holdLiveResizeSnapshotForReason:(NSString *)reason;
    1582 @end
    1583 
    1584 #endif // HAVE(MAC_CATALYST_LIVE_RESIZE)
    1585 
    15861589WTF_EXTERN_C_BEGIN
    15871590
  • trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp

    r293994 r295360  
    191191#endif
    192192
    193 #if HAVE(MULTITASKING_MODE)
    194     encoder << isInMultitaskingMode;
     193#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     194    encoder << hasResizableWindows;
    195195#endif
    196196
    … …  
    606606#endif
    607607
    608 #if HAVE(MULTITASKING_MODE)
    609     if (!decoder.decode(parameters.isInMultitaskingMode))
     608#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     609    if (!decoder.decode(parameters.hasResizableWindows))
    610610        return std::nullopt;
    611611#endif
  • trunk/Source/WebKit/Shared/WebPageCreationParameters.h

    r293994 r295360  
    267267#endif
    268268
    269     bool isInMultitaskingMode { false };
     269    bool hasResizableWindows { false };
    270270
    271271    WebCore::ContentSecurityPolicyModeForExtension contentSecurityPolicyModeForExtension { WebCore::ContentSecurityPolicyModeForExtension::None };
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r295346 r295360  
    659659#endif
    660660
    661 #if HAVE(MAC_CATALYST_LIVE_RESIZE)
     661#if HAVE(UIKIT_RESIZABLE_WINDOWS)
    662662    [self _invalidateResizeAssertions];
    663663#endif
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h

    r293231 r295360  
    224224    double _scaleToRestore;
    225225
    226 #if HAVE(MAC_CATALYST_LIVE_RESIZE)
     226#if HAVE(UIKIT_RESIZABLE_WINDOWS)
    227227    Vector<RetainPtr<id<_UIInvalidatable>>> _resizeAssertions;
    228228#endif
  • trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h

    r295223 r295360  
    5353
    5454- (void)_frameOrBoundsChanged;
    55 #if HAVE(MAC_CATALYST_LIVE_RESIZE)
     55#if HAVE(UIKIT_RESIZABLE_WINDOWS)
    5656- (void)_invalidateResizeAssertions;
    5757#endif
    … …  
    173173@property (nonatomic, readonly) int32_t _deviceOrientation;
    174174
    175 #if HAVE(MULTITASKING_MODE)
    176 @property (nonatomic, readonly) BOOL _isInMultitaskingMode;
     175#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     176@property (nonatomic, readonly) BOOL _isWindowResizingEnabled;
    177177#endif
    178178
  • trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm

    r295223 r295360  
    124124        [self _frameOrBoundsChanged];
    125125
    126 #if HAVE(MAC_CATALYST_LIVE_RESIZE)
     126#if HAVE(UIKIT_RESIZABLE_WINDOWS)
    127127        [self _acquireResizeAssertionForReason:@"-[WKWebView setFrame:]"];
    128128#endif
    … …  
    139139        [self _frameOrBoundsChanged];
    140140
    141 #if HAVE(MAC_CATALYST_LIVE_RESIZE)
     141#if HAVE(UIKIT_RESIZABLE_WINDOWS)
    142142        [self _acquireResizeAssertionForReason:@"-[WKWebView setBounds:]"];
    143143#endif
    … …  
    197197    [center addObserver:self selector:@selector(_accessibilitySettingsDidChange:) name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];
    198198
    199 #if HAVE(MULTITASKING_MODE)
    200     [center addObserver:self selector:@selector(_multitaskingModeDidChange:) name:self.multitaskingModeChangedNotificationName object:nil];
     199#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     200    [center addObserver:self selector:@selector(_enhancedWindowingToggled:) name:_UIWindowSceneEnhancedWindowingModeChanged object:nil];
    201201#endif
    202202}
    … …  
    707707    [self _cancelAnimatedResize];
    708708
    709 #if HAVE(MAC_CATALYST_LIVE_RESIZE)
     709#if HAVE(UIKIT_RESIZABLE_WINDOWS)
    710710    [self _invalidateResizeAssertions];
    711711#endif
    … …  
    15631563    _page->webViewDidMoveToWindow();
    15641564    [self _presentCaptivePortalModeAlertIfNeeded];
    1565 #if HAVE(MULTITASKING_MODE)
     1565#if HAVE(UIKIT_RESIZABLE_WINDOWS)
    15661566    if (_page->hasRunningProcess() && self.window)
    1567         _page->setIsInMultitaskingMode(self._isInMultitaskingMode);
    1568 #endif
    1569 #if HAVE(MAC_CATALYST_LIVE_RESIZE)
     1567        _page->setIsWindowResizingEnabled(self._isWindowResizingEnabled);
     1568#endif
     1569#if HAVE(UIKIT_RESIZABLE_WINDOWS)
    15701570    [self _invalidateResizeAssertions];
    15711571#endif
    15721572}
     1573
     1574#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     1575
     1576- (BOOL)_isWindowResizingEnabled
     1577{
     1578    UIWindowScene *scene = self.window.windowScene;
     1579    return [scene respondsToSelector:@selector(_enhancedWindowingEnabled)] && scene._enhancedWindowingEnabled;
     1580}
     1581
     1582#endif // HAVE(UIKIT_RESIZABLE_WINDOWS)
    15731583
    15741584- (void)_setOpaqueInternal:(BOOL)opaque
    … …  
    20062016}
    20072017
    2008 #if HAVE(MAC_CATALYST_LIVE_RESIZE)
     2018#if HAVE(UIKIT_RESIZABLE_WINDOWS)
    20092019
    20102020- (void)_acquireResizeAssertionForReason:(NSString *)reason
    … …  
    20562066}
    20572067
    2058 #endif // HAVE(MAC_CATALYST_LIVE_RESIZE)
     2068#endif // HAVE(UIKIT_RESIZABLE_WINDOWS)
    20592069
    20602070// Unobscured content rect where the user can interact. When the keyboard is up, this should be the area above or below the keyboard, wherever there is enough space.
    … …  
    27602770#endif
    27612771
    2762 #if HAVE(MULTITASKING_MODE)
    2763 
    2764 - (void)_multitaskingModeDidChange:(NSNotification *)notification
     2772#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     2773
     2774- (void)_enhancedWindowingToggled:(NSNotification *)notification
    27652775{
    27662776    if (dynamic_objc_cast<UIWindowScene>(notification.object) != self.window.windowScene)
    … …  
    27702780        return;
    27712781
    2772     _page->setIsInMultitaskingMode(self._isInMultitaskingMode);
    2773 }
    2774 
    2775 #endif // HAVE(MULTITASKING_MODE)
     2782    _page->setIsWindowResizingEnabled(self._isWindowResizingEnabled);
     2783}
     2784
     2785#endif // HAVE(UIKIT_RESIZABLE_WINDOWS)
    27762786
    27772787@end
    … …  
    32753285    CGFloat oldWebViewWidthInContentViewCoordinates = oldUnobscuredContentRect.width();
    32763286    _animatedResizeOriginalContentWidth = [&] {
    3277 #if HAVE(MULTITASKING_MODE)
    3278         if (self._isInMultitaskingMode)
     3287#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     3288        if (self._isWindowResizingEnabled)
    32793289            return contentSizeInContentViewCoordinates.width;
    32803290#endif
  • trunk/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm

    r294589 r295360  
    484484- (BOOL)_hasResizeAssertion
    485485{
    486 #if HAVE(MAC_CATALYST_LIVE_RESIZE)
     486#if HAVE(UIKIT_RESIZABLE_WINDOWS)
    487487    if (!_resizeAssertions.isEmpty())
    488488        return YES;
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r295346 r295360  
    555555#endif
    556556
    557     virtual bool isInMultitaskingMode() const { return false; }
     557    virtual bool hasResizableWindows() const { return false; }
    558558
    559559#if ENABLE(IMAGE_ANALYSIS)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r295346 r295360  
    85248524#endif
    85258525
    8526 #if HAVE(MULTITASKING_MODE)
    8527     parameters.isInMultitaskingMode = pageClient().isInMultitaskingMode();
     8526#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     8527    parameters.hasResizableWindows = pageClient().hasResizableWindows();
    85288528#endif
    85298529
    … …  
    1141711417#endif
    1141811418
    11419 #if HAVE(MULTITASKING_MODE)
    11420 
    11421 void WebPageProxy::setIsInMultitaskingMode(bool isInMultitaskingMode)
    11422 {
    11423     send(Messages::WebPage::SetIsInMultitaskingMode(isInMultitaskingMode));
     11419#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     11420
     11421void WebPageProxy::setIsWindowResizingEnabled(bool hasResizableWindows)
     11422{
     11423    send(Messages::WebPage::SetIsWindowResizingEnabled(hasResizableWindows));
    1142411424}
    1142511425
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r295346 r295360  
    21112111#endif
    21122112
    2113 #if HAVE(MULTITASKING_MODE)
    2114     void setIsInMultitaskingMode(bool);
     2113#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     2114    void setIsWindowResizingEnabled(bool);
    21152115#endif
    21162116
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h

    r295346 r295360  
    311311    void cancelElementFullscreenVideoExtraction() final;
    312312
    313     bool isInMultitaskingMode() const final;
     313    bool hasResizableWindows() const final;
    314314
    315315#if ENABLE(VIDEO_PRESENTATION_MODE)
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm

    r295346 r295360  
    10841084}
    10851085
    1086 bool PageClientImpl::isInMultitaskingMode() const
    1087 {
    1088 #if HAVE(MULTITASKING_MODE)
    1089     return [m_webView _isInMultitaskingMode];
     1086bool PageClientImpl::hasResizableWindows() const
     1087{
     1088#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     1089    return [m_webView _isWindowResizingEnabled];
    10901090#else
    10911091    return false;
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r295337 r295360  
    13981398
    13991399#if !PLATFORM(MACCATALYST)
    1400     if (!pageClient().isInMultitaskingMode() && webViewSizeIsNarrow(viewSize()))
     1400    if (!pageClient().hasResizableWindows() && webViewSizeIsNarrow(viewSize()))
    14011401        return false;
    14021402#endif
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r295346 r295360  
    542542    , m_requiresUserActionForEditingControlsManager(parameters.requiresUserActionForEditingControlsManager)
    543543#endif
    544 #if HAVE(MULTITASKING_MODE)
    545     , m_isInMultitaskingMode(parameters.isInMultitaskingMode)
     544#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     545    , m_isWindowResizingEnabled(parameters.hasResizableWindows)
    546546#endif
    547547#if ENABLE(META_VIEWPORT)
    … …  
    67036703    bool viewportChanged = false;
    67046704
    6705     m_viewportConfiguration.setPrefersHorizontalScrollingBelowDesktopViewportWidths(usesMultitaskingModeViewportBehaviors());
     6705    m_viewportConfiguration.setPrefersHorizontalScrollingBelowDesktopViewportWidths(shouldEnableViewportBehaviorsForResizableWindows());
    67066706
    67076707    LOG_WITH_STREAM(VisibleRects, stream << "WebPage " << m_identifier.toUInt64() << " didCommitLoad setting content size to " << coreFrame->view()->contentsSize());
    … …  
    81168116#endif
    81178117
    8118 #if HAVE(MULTITASKING_MODE)
    8119 
    8120 void WebPage::setIsInMultitaskingMode(bool value)
    8121 {
    8122     if (m_isInMultitaskingMode == value)
    8123         return;
    8124 
    8125     m_isInMultitaskingMode = value;
    8126     m_viewportConfiguration.setPrefersHorizontalScrollingBelowDesktopViewportWidths(usesMultitaskingModeViewportBehaviors());
    8127 }
    8128 
    8129 #endif // HAVE(MULTITASKING_MODE)
     8118#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     8119
     8120void WebPage::setIsWindowResizingEnabled(bool value)
     8121{
     8122    if (m_isWindowResizingEnabled == value)
     8123        return;
     8124
     8125    m_isWindowResizingEnabled = value;
     8126    m_viewportConfiguration.setPrefersHorizontalScrollingBelowDesktopViewportWidths(shouldEnableViewportBehaviorsForResizableWindows());
     8127}
     8128
     8129#endif // HAVE(UIKIT_RESIZABLE_WINDOWS)
    81308130
    81318131bool WebPage::handlesPageScaleGesture()
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r295346 r295360  
    15481548#endif
    15491549
    1550 #if HAVE(MULTITASKING_MODE)
    1551     void setIsInMultitaskingMode(bool);
     1550#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     1551    void setIsWindowResizingEnabled(bool);
    15521552#endif
    15531553
    … …  
    18021802
    18031803#if ENABLE(META_VIEWPORT)
    1804     bool usesMultitaskingModeViewportBehaviors() const;
     1804    bool shouldEnableViewportBehaviorsForResizableWindows() const;
    18051805#endif
    18061806
    … …  
    22752275    OptionSet<WebCore::ActivityState::Flag> m_lastActivityStateChanges;
    22762276
    2277 #if HAVE(MULTITASKING_MODE)
    2278     bool m_isInMultitaskingMode { false };
     2277#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     2278    bool m_isWindowResizingEnabled { false };
    22792279#endif
    22802280
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r295346 r295360  
    688688#endif
    689689
    690 #if HAVE(MULTITASKING_MODE)
    691     SetIsInMultitaskingMode(bool isInMultitaskingMode)
     690#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     691    SetIsWindowResizingEnabled(bool hasResizableWindows)
    692692#endif
    693693}
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r295351 r295360  
    36563656    float relativeHorizontalPositionInNodeAtCenter = 0;
    36573657    float relativeVerticalPositionInNodeAtCenter = 0;
    3658     if (!usesMultitaskingModeViewportBehaviors()) {
     3658    if (!shouldEnableViewportBehaviorsForResizableWindows()) {
    36593659        visibleHorizontalFraction = frameView.unobscuredContentSize().width() / oldContentSize.width();
    36603660        IntPoint unobscuredContentRectCenter = frameView.unobscuredContentRect().center();
    … …  
    36963696    IntSize newContentSize = frameView.contentsSize();
    36973697
    3698     bool scaleToFitContent = (!usesMultitaskingModeViewportBehaviors() || !wasAtInitialScale) && m_userHasChangedPageScaleFactor;
     3698    bool scaleToFitContent = (!shouldEnableViewportBehaviorsForResizableWindows() || !wasAtInitialScale) && m_userHasChangedPageScaleFactor;
    36993699    double scale = scaleAfterViewportWidthChange(targetScale, scaleToFitContent, m_viewportConfiguration, targetUnobscuredRectInScrollViewCoordinates.width(), newContentSize, oldContentSize, visibleHorizontalFraction);
    37003700    FloatRect newUnobscuredContentRect = targetUnobscuredRect;
    … …  
    37123712        double newUnobscuredRectX;
    37133713        double newUnobscuredRectY;
    3714         if (usesMultitaskingModeViewportBehaviors()) {
     3714        if (shouldEnableViewportBehaviorsForResizableWindows()) {
    37153715            newUnobscuredRectX = oldUnobscuredContentRect.x();
    37163716            newUnobscuredRectY = oldUnobscuredContentRect.y();
    … …  
    39933993}
    39943994
    3995 bool WebPage::usesMultitaskingModeViewportBehaviors() const
    3996 {
    3997 #if HAVE(MULTITASKING_MODE)
    3998     return shouldIgnoreMetaViewport() && m_isInMultitaskingMode;
     3995bool WebPage::shouldEnableViewportBehaviorsForResizableWindows() const
     3996{
     3997#if HAVE(UIKIT_RESIZABLE_WINDOWS)
     3998    return shouldIgnoreMetaViewport() && m_isWindowResizingEnabled;
    39993999#else
    40004000    return false;
Note: See TracChangeset for help on using the changeset viewer.