Skip to content

Commit

Permalink
Cherry-pick 5cdf58d. rdar://121706323
Browse files Browse the repository at this point in the history
    Cherry-pick 274016@main (98226f6). rdar://problem/121706323

        [iOS] Update SPI headers for iOS 17.4
        https://bugs.webkit.org/show_bug.cgi?id=268210
        rdar://problem/121706323

        Reviewed by Jonathan Bedard and Alexey Proskuryakov.

        Add platform flags for libxpc (which is API as of iOS 17.4+) and for
        other SPI that were promoted to API as part of the BrowserEngineKit
        introduction. Use them to avoid redeclaring things that are now
        publicly available.

        Additionally, write new BrowserEngineKit SPI declarations for symbols
        that are used in testing and by SPI clients of WebKit.

        * Source/WTF/wtf/PlatformHave.h:
        * Source/WTF/wtf/spi/cocoa/IOSurfaceSPI.h:
        * Source/WTF/wtf/spi/darwin/XPCSPI.h:
        * Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h:
        * Source/WebCore/PAL/pal/spi/ios/BrowserEngineKitSPI.h:
        * Source/WebKit/Platform/spi/ios/UIKitSPI.h:
        * Tools/TestRunnerShared/spi/UIKitSPIForTesting.h:

        Canonical link: https://commits.webkit.org/274016@main

    Canonical link: https://commits.webkit.org/272448.522@safari-7618-branch

Identifier: 272448.530@safari-7618.1.15.12-branch
  • Loading branch information
emw-apple authored and MyahCobbs committed Feb 8, 2024
1 parent 5e0a563 commit 9952c70
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 13 deletions.
12 changes: 12 additions & 0 deletions Source/WTF/wtf/PlatformHave.h
Original file line number Diff line number Diff line change
Expand Up @@ -1701,3 +1701,15 @@
&& (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170400)
#define HAVE_MARKETPLACE_KIT 1
#endif

#if !defined(HAVE_XPC_API) \
&& (PLATFORM(MAC) \
|| ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170400))
#define HAVE_XPC_API 1
#endif

#if !defined(HAVE_BROWSER_ENGINE_SUPPORTING_API) \
&& (((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170400) \
|| (PLATFORM(APPLETV) && __TV_OS_VERSION_MAX_ALLOWED >= 170400))
#define HAVE_BROWSER_ENGINE_SUPPORTING_API 1
#endif
2 changes: 1 addition & 1 deletion Source/WTF/wtf/spi/cocoa/IOSurfaceSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ WTF_EXTERN_C_END

WTF_EXTERN_C_BEGIN

#if HAVE(IOSURFACE_SET_OWNERSHIP) || HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
#if (HAVE(IOSURFACE_SET_OWNERSHIP) || HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)) && !HAVE(BROWSER_ENGINE_SUPPORTING_API)
typedef CF_ENUM(int, IOSurfaceMemoryLedgerTags)
{
kIOSurfaceMemoryLedgerTagDefault = 0x00000001,
Expand Down
2 changes: 1 addition & 1 deletion Source/WTF/wtf/spi/darwin/XPCSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <dispatch/dispatch.h>
#include <os/object.h>

#if PLATFORM(MAC) || USE(APPLE_INTERNAL_SDK)
#if HAVE(XPC_API) || USE(APPLE_INTERNAL_SDK)
#include <xpc/xpc.h>
#else

Expand Down
21 changes: 12 additions & 9 deletions Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,17 @@ NS_ASSUME_NONNULL_END
#endif

#if HAVE(AVCONTENTKEYREQUEST_PENDING_PROTECTION_STATUS)
#if !HAVE(BROWSER_ENGINE_SUPPORTING_API)
typedef NS_ENUM(NSInteger, AVExternalContentProtectionStatus) {
AVExternalContentProtectionStatusPending = 0,
AVExternalContentProtectionStatusSufficient = 1,
AVExternalContentProtectionStatusInsufficient = 2,
};

#endif
@interface AVContentKeyRequest (AVContentKeyRequest_PendingProtectionStatus)
- (AVExternalContentProtectionStatus)externalContentProtectionStatus;
@end
#endif
#endif // HAVE(AVCONTENTKEYREQUEST_PENDING_PROTECTION_STATUS)

#if HAVE(AVCONTENTKEYREQUEST_COMPATABILITIY_MODE)
NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -383,21 +384,23 @@ NS_ASSUME_NONNULL_END

#endif // __has_include(<AVFoundation/AVSampleBufferAudioRenderer.h>)

#if !USE(APPLE_INTERNAL_SDK)
@interface AVVideoPerformanceMetrics : NSObject
@property (nonatomic, readonly) unsigned long totalNumberOfVideoFrames;
@property (nonatomic, readonly) unsigned long numberOfDroppedVideoFrames;
@property (nonatomic, readonly) unsigned long numberOfCorruptedVideoFrames;
#if HAVE(BROWSER_ENGINE_SUPPORTING_API)
#import <AVFoundation/AVVideoPerformanceMetrics.h>
@interface AVVideoPerformanceMetrics (AVVideoPerformanceMetricsDisplayCompositedVideoFrames)
@property (nonatomic, readonly) unsigned long numberOfDisplayCompositedVideoFrames;
@property (nonatomic, readonly) unsigned long numberOfNonDisplayCompositedVideoFrames;
@property (nonatomic, readonly) double totalFrameDelay;
@end
#else
@interface AVVideoPerformanceMetrics (AVVideoPerformanceMetricsDisplayCompositedVideoFrames)
@interface AVVideoPerformanceMetrics : NSObject
@property (nonatomic, readonly) unsigned long totalNumberOfVideoFrames;
@property (nonatomic, readonly) unsigned long numberOfDroppedVideoFrames;
@property (nonatomic, readonly) unsigned long numberOfCorruptedVideoFrames;
@property (nonatomic, readonly) unsigned long numberOfDisplayCompositedVideoFrames;
@property (nonatomic, readonly) unsigned long numberOfNonDisplayCompositedVideoFrames;
@property (nonatomic, readonly) double totalFrameDelay;
@end
#endif
#endif // HAVE(BROWSER_ENGINE_SUPPORTING_API)

#if !USE(APPLE_INTERNAL_SDK) && HAVE(AVAUDIOSESSION) && !PLATFORM(MACCATALYST)
#import <AVFoundation/AVAudioSession.h>
Expand Down
68 changes: 68 additions & 0 deletions Source/WebCore/PAL/pal/spi/ios/BrowserEngineKitSPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (C) 2024 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.
*/

#pragma once

#if USE(BROWSERENGINEKIT)

#import <BrowserEngineKit/BrowserEngineKit.h>

#if USE(APPLE_INTERNAL_SDK)
// Note: SPI usage should be limited to testing purposes and binary compatibility with clients
// of existing WebKit SPI.
#import <BrowserEngineKit/BrowserEngineKit_Private.h>
#endif

@class NSTextAlternatives;
@class UIKeyEvent;
@class UITextSuggestion;
@class UIWKDocumentContext;

@interface BEKeyEntry (ForTesting)
- (UIKeyEvent *)_uikitKeyEvent;
- (instancetype)_initWithUIKitKeyEvent:(UIKeyEvent *)keyEvent;
@end

@interface BETextAlternatives ()
@property (readonly) BOOL isLowConfidence;
- (NSTextAlternatives *)_nsTextAlternative;
- (instancetype)_initWithNSTextAlternatives:(NSTextAlternatives *)nsTextAlternatives;
@end

@interface BETextDocumentContext ()
@property (strong, nonatomic, readonly) UIWKDocumentContext *_uikitDocumentContext;
@property (nonatomic, copy) NSAttributedString *annotatedText;
@end

@interface BETextDocumentRequest ()
@property (nonatomic, assign) CGRect _documentRect;
@end

@interface BETextSuggestion ()
@property (nonatomic, readonly, strong) UITextSuggestion *_uikitTextSuggestion;
- (instancetype)_initWithUIKitTextSuggestion:(UITextSuggestion *)suggestion;
@end

#endif // USE(BROWSERENGINEKIT)
2 changes: 2 additions & 0 deletions Source/WebKit/Platform/spi/ios/UIKitSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,10 @@ typedef struct CGSVGDocument *CGSVGDocumentRef;
@property (nonatomic, readonly) UIEdgeInsets _systemContentInset;
@property (nonatomic, getter=_allowsAsyncScrollEvent, setter=_setAllowsAsyncScrollEvent:) BOOL _allowsAsyncScrollEvent;
@property (nonatomic, getter=_isFirstResponderKeyboardAvoidanceEnabled, setter=_setFirstResponderKeyboardAvoidanceEnabled:) BOOL firstResponderKeyboardAvoidanceEnabled;
#if !HAVE(BROWSER_ENGINE_SUPPORTING_API)
@property (nonatomic) BOOL bouncesHorizontally;
@property (nonatomic) BOOL bouncesVertically;
#endif
@property (nonatomic, setter=_setAllowsParentToBeginHorizontally:) BOOL _allowsParentToBeginHorizontally;
@property (nonatomic, setter=_setAllowsParentToBeginVertically:) BOOL _allowsParentToBeginVertically;
@property (nonatomic) BOOL tracksImmediatelyWhileDecelerating;
Expand Down
5 changes: 3 additions & 2 deletions Tools/TestRunnerShared/spi/UIKitSPIForTesting.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ WTF_EXTERN_C_END

@interface UITextSuggestion : NSObject
@property (nonatomic, copy) NSString *displayText;
+ (instancetype)textSuggestionWithInputText:(NSString *)inputText;
@end

@protocol UITextInputTraits_Private <NSObject, UITextInputTraits>
Expand Down Expand Up @@ -622,8 +623,8 @@ typedef NS_ENUM(NSInteger, NSTextBlockLayer) {
@end
#endif

#if HAVE(UI_ASYNC_TEXT_INTERACTION)
@interface UIKeyEvent (Internal)
#if USE(BROWSERENGINEKIT)
@interface UIKeyEvent : NSObject
- (instancetype)initWithWebEvent:(WebEvent *)webEvent;
@property (nonatomic, readonly) WebEvent *webEvent;
@end
Expand Down

0 comments on commit 9952c70

Please sign in to comment.