Skip to content

Commit

Permalink
Stop using the UIApp static variable to access the shared UIApplica…
Browse files Browse the repository at this point in the history
…tion

https://bugs.webkit.org/show_bug.cgi?id=261861

Reviewed by Richard Robinson.

Replace uses of `UIApp` with the equivalent `+[UIApplication sharedApplication]`. Also, remove a
staging declaration for the `-[UIView focusEffect]` property that's no longer necessary.

* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::didChangeIsLoading):
* Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant showImageSheet]):
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView actionSheetAssistant:showCustomSheetForElement:]):
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::applicationDidEnterBackground):
(WebKit::WebPageProxy::applicationWillEnterForeground):
(WebKit::WebPageProxy::applicationDidEnterBackgroundForMedia):
(WebKit::WebPageProxy::applicationWillEnterForegroundForMedia):
* Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
(-[WKFullScreenViewController viewWillTransitionToSize:withTransitionCoordinator:]):
* Tools/DumpRenderTree/mac/DumpRenderTree.mm:
(createWebViewAndOffscreenWindow):
(runTest):

Canonical link: https://commits.webkit.org/268235@main
  • Loading branch information
whsieh committed Sep 21, 2023
1 parent c4193e7 commit fceec34
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 23 deletions.
9 changes: 0 additions & 9 deletions Source/WebKit/Platform/spi/ios/UIKitSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -1330,14 +1330,6 @@ typedef NS_ENUM(NSUInteger, _UIScrollDeviceCategory) {
@property (nonatomic, copy, setter=_setSuggestedColors:) NSArray<UIColor *> *_suggestedColors;
@end

#if HAVE(UI_FOCUS_EFFECT)
@class UIFocusEffect;

@interface UIView (Staging_75759822)
@property (nonatomic, readwrite, copy) UIFocusEffect *focusEffect;
@end
#endif

#if HAVE(UIFINDINTERACTION)

@interface _UIFindInteraction (Staging_84486967)
Expand Down Expand Up @@ -1372,7 +1364,6 @@ extern NSString * const UIKeyboardPrivateDidRequestDismissalNotification;

extern NSString * const UIKeyboardIsLocalUserInfoKey;

extern UIApplication *UIApp;
BOOL _UIApplicationIsExtension(void);
void _UIApplicationLoadWebKit(void);

Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/Cocoa/NavigationState.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ static _WKSOAuthorizationLoadPolicy wkSOAuthorizationLoadPolicy(SOAuthorizationL
if (webView && webView->_page->pageLoadState().isLoading()) {
#if PLATFORM(IOS_FAMILY)
// We do not start a network activity if a load starts after the screen has been locked.
if ([UIApp isSuspendedUnderLock])
if (UIApplication.sharedApplication.isSuspendedUnderLock)
return;
#endif

Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ - (void)showImageSheet
return;

if (!alternateURL && userInfo) {
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
[UIApp _cancelAllTouches];
ALLOW_DEPRECATED_DECLARATIONS_END
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
[UIApplication.sharedApplication _cancelAllTouches];
ALLOW_DEPRECATED_DECLARATIONS_END
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8496,7 +8496,7 @@ - (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant showCustomSheet

// Prevent tap-and-hold and panning.
if (shouldCancelAllTouches)
[UIApp _cancelAllTouches];
[UIApplication.sharedApplication _cancelAllTouches];

return YES;
}
Expand Down
8 changes: 4 additions & 4 deletions Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ static inline float adjustedUnexposedMaxEdge(float documentEdge, float exposedRe
{
m_lastObservedStateWasBackground = true;

bool isSuspendedUnderLock = [UIApp isSuspendedUnderLock];
bool isSuspendedUnderLock = UIApplication.sharedApplication.isSuspendedUnderLock;

WEBPAGEPROXY_RELEASE_LOG(ViewState, "applicationDidEnterBackground: isSuspendedUnderLock? %d", isSuspendedUnderLock);

Expand Down Expand Up @@ -661,7 +661,7 @@ static inline float adjustedUnexposedMaxEdge(float documentEdge, float exposedRe
{
m_lastObservedStateWasBackground = false;

bool isSuspendedUnderLock = [UIApp isSuspendedUnderLock];
bool isSuspendedUnderLock = UIApplication.sharedApplication.isSuspendedUnderLock;
WEBPAGEPROXY_RELEASE_LOG(ViewState, "applicationWillEnterForeground: isSuspendedUnderLock? %d", isSuspendedUnderLock);

m_process->send(Messages::WebPage::ApplicationWillEnterForeground(isSuspendedUnderLock), webPageID());
Expand All @@ -675,15 +675,15 @@ static inline float adjustedUnexposedMaxEdge(float documentEdge, float exposedRe

void WebPageProxy::applicationDidEnterBackgroundForMedia()
{
bool isSuspendedUnderLock = [UIApp isSuspendedUnderLock];
bool isSuspendedUnderLock = UIApplication.sharedApplication.isSuspendedUnderLock;
WEBPAGEPROXY_RELEASE_LOG(ViewState, "applicationWillEnterForegroundForMedia: isSuspendedUnderLock? %d", isSuspendedUnderLock);

m_process->send(Messages::WebPage::ApplicationDidEnterBackgroundForMedia(isSuspendedUnderLock), webPageID());
}

void WebPageProxy::applicationWillEnterForegroundForMedia()
{
bool isSuspendedUnderLock = [UIApp isSuspendedUnderLock];
bool isSuspendedUnderLock = UIApplication.sharedApplication.isSuspendedUnderLock;
WEBPAGEPROXY_RELEASE_LOG(ViewState, "applicationWillEnterForegroundForMedia: isSuspendedUnderLock? %d", isSuspendedUnderLock);

m_process->send(Messages::WebPage::ApplicationWillEnterForegroundForMedia(isSuspendedUnderLock), webPageID());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,9 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIVi
[self._webView _beginAnimatedResizeWithUpdates:^{
[self._webView _overrideLayoutParametersWithMinimumLayoutSize:size maximumUnobscuredSizeOverride:size];
}];
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
[self._webView _setInterfaceOrientationOverride:[UIApp statusBarOrientation]];
ALLOW_DEPRECATED_DECLARATIONS_END
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
[self._webView _setInterfaceOrientationOverride:UIApplication.sharedApplication.statusBarOrientation];
ALLOW_DEPRECATED_DECLARATIONS_END
} completion:^(id <UIViewControllerTransitionCoordinatorContext>context) {
[self._webView _endAnimatedResize];
}];
Expand Down
4 changes: 2 additions & 2 deletions Tools/DumpRenderTree/mac/DumpRenderTree.mm
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ static void registerMockScrollbars()
[[webView window] makeFirstResponder:[[[webView mainFrame] frameView] documentView]];

CGRect uiWindowRect = layoutTestViewportRect;
uiWindowRect.origin.y += [UIApp statusBarHeight];
uiWindowRect.origin.y += UIApplication.sharedApplication.statusBarHeight;
auto uiWindow = adoptNS([[UIWindow alloc] initWithFrame:uiWindowRect]);

auto viewController = adoptNS([[UIViewController alloc] init]);
Expand Down Expand Up @@ -2010,7 +2010,7 @@ static void runTest(const std::string& inputLine)
}

#if PLATFORM(IOS_FAMILY)
[(DumpRenderTree *)UIApp _waitForWebThread];
[(DumpRenderTree *)UIApplication.sharedApplication _waitForWebThread];
WebThreadLockAfterDelegateCallbacksHaveCompleted();
#endif

Expand Down

0 comments on commit fceec34

Please sign in to comment.