Skip to content

Commit 3e4424e

Browse files
Matthew BenedictMatthew Benedict
authored andcommitted
CyberKit v0.0.8 alpha
1 parent 212fd7c commit 3e4424e

14 files changed

Lines changed: 135 additions & 11 deletions

File tree

Source/CyberCore/PAL/pal/spi/cf/CFNetworkSPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ typedef NS_ENUM(NSInteger, NSURLSessionCompanionProxyPreference) {
300300
@interface NSURLSessionTask ()
301301
#if HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION_OBJECT)
302302
- (void)_adoptEffectiveConfiguration:(NSURLSessionEffectiveConfiguration *) newConfiguration;
303-
#else
303+
#elif HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
304304
- (void)_adoptEffectiveConfiguration:(NSURLSessionConfiguration *) newConfiguration;
305305
#endif
306306
- (NSDictionary *)_timingData;

Source/CyberCore/platform/cocoa/ContentFilterUnblockHandlerCocoa.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@
9898
NSError *error { nil };
9999
NSSet<Class> *classes = [NSSet setWithObjects:getWebFilterEvaluatorClass(), NSNumber.class, NSURL.class, NSString.class, NSMutableString.class, nil];
100100
NSData *data = [NSData dataWithBytesNoCopy:vector.data() length:vector.size() freeWhenDone:NO];
101-
return [NSKeyedUnarchiver _strictlyUnarchivedObjectOfClasses:classes fromData:data error:&error];
101+
if ([NSKeyedUnarchiver respondsToSelector:@selector(_strictlyUnarchivedObjectOfClasses:fromData:error:)])
102+
return [NSKeyedUnarchiver _strictlyUnarchivedObjectOfClasses:classes fromData:data error:&error];
103+
else
104+
return [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:data error:&error];
102105
}
103106
#endif
104107

Source/CyberCore/platform/graphics/cocoa/FontCacheCoreText.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,13 @@ SynthesisPair computeNecessarySynthesis(CTFontRef font, const FontDescription& f
252252

253253
CTFontSymbolicTraits actualTraits = 0;
254254
if (isFontWeightBold(fontDescription.weight()) || isItalic(fontDescription.italic())) {
255+
#if !PLATFORM(IOS_FAMILY) || __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
255256
if (shouldComputePhysicalTraits == ShouldComputePhysicalTraits::Yes)
256257
actualTraits = CTFontGetPhysicalSymbolicTraits(font);
257258
else
259+
#else
260+
UNUSED_PARAM(shouldComputePhysicalTraits);
261+
#endif
258262
actualTraits = CTFontGetSymbolicTraits(font);
259263
}
260264

@@ -735,8 +739,13 @@ static bool isUserInstalledFont(CTFontRef font)
735739
static RetainPtr<CTFontRef> createFontForCharacters(CTFontRef font, CFStringRef localeString, AllowUserInstalledFonts allowUserInstalledFonts, const UChar* characters, unsigned length)
736740
{
737741
CFIndex coveredLength = 0;
742+
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
738743
auto fallbackOption = allowUserInstalledFonts == AllowUserInstalledFonts::No ? kCTFontFallbackOptionSystem : kCTFontFallbackOptionDefault;
739744
return adoptCF(CTFontCreateForCharactersWithLanguageAndOption(font, reinterpret_cast<const UniChar*>(characters), length, localeString, fallbackOption, &coveredLength));
745+
#else
746+
UNUSED_PARAM(allowUserInstalledFonts);
747+
return adoptCF(CTFontCreateForCharactersWithLanguage(font, reinterpret_cast<const UniChar*>(characters), length, localeString, &coveredLength));
748+
#endif
740749
}
741750

742751
static RetainPtr<CTFontRef> lookupFallbackFont(CTFontRef font, FontSelectionValue fontWeight, const AtomString& locale, AllowUserInstalledFonts allowUserInstalledFonts, const UChar* characters, unsigned length)
@@ -955,7 +964,11 @@ void FontCache::prewarm(PrewarmInformation&& prewarmInformation)
955964
CFIndex coveredLength = 0;
956965
UniChar character = ' ';
957966

967+
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
958968
auto fallbackWarmingFont = adoptCF(CTFontCreateForCharactersWithLanguageAndOption(warmingFont.get(), &character, 1, nullptr, kCTFontFallbackOptionSystem, &coveredLength));
969+
#else
970+
auto fallbackWarmingFont = adoptCF(CTFontCreateForCharactersWithLanguage(warmingFont.get(), &character, 1, nullptr, &coveredLength));
971+
#endif
959972
}
960973
}
961974
});

Source/CyberCore/platform/graphics/cocoa/GraphicsContextCocoa.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static inline void drawDotsForDocumentMarker(CGContextRef context, const FloatRe
157157

158158
void GraphicsContextCG::convertToDestinationColorSpaceIfNeeded(RetainPtr<CGImageRef>& image)
159159
{
160-
#if HAVE(CORE_ANIMATION_FIX_FOR_RADAR_93560567)
160+
#if HAVE(CORE_ANIMATION_FIX_FOR_RADAR_93560567) || ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MIN_REQUIRED < 140000)
161161
UNUSED_PARAM(image);
162162
#else
163163
if (!CGColorSpaceUsesITUR_2100TF(CGImageGetColorSpace(image.get())))

Source/CyberKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ static inline bool computeIsAlwaysOnLoggingAllowed(NetworkSession& session)
429429

430430
WTFBeginSignpost(m_task.get(), "DataTask", "%" PUBLIC_LOG_STRING " %" PRIVATE_LOG_STRING " pri: %.2f preconnect: %d", request.httpMethod().utf8().data(), url.string().utf8().data(), toNSURLSessionTaskPriority(request.priority()), parameters.shouldPreconnectOnly == PreconnectOnly::Yes);
431431

432+
#if HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
432433
switch (parameters.storedCredentialsPolicy) {
433434
case CyberCore::StoredCredentialsPolicy::Use:
434435
ASSERT(m_sessionWrapper->session.get().configuration.URLCredentialStorage);
@@ -449,6 +450,7 @@ static inline bool computeIsAlwaysOnLoggingAllowed(NetworkSession& session)
449450
#endif
450451
break;
451452
};
453+
#endif
452454

453455
RELEASE_ASSERT(!m_sessionWrapper->dataTaskMap.contains([m_task taskIdentifier]));
454456
m_sessionWrapper->dataTaskMap.add([m_task taskIdentifier], this);

Source/CyberKit/NetworkProcess/cocoa/NetworkSessionCocoa.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ struct IsolatedSession {
7575
WTF_MAKE_FAST_ALLOCATED;
7676
public:
7777
SessionWrapper sessionWithCredentialStorage;
78+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
79+
SessionWrapper sessionWithoutCredentialStorage;
80+
#endif
7881
WallTime lastUsed;
7982
};
8083

@@ -93,6 +96,9 @@ struct SessionSet : public RefCounted<SessionSet>, public CanMakeWeakPtr<Session
9396
std::unique_ptr<IsolatedSession> appBoundSession;
9497

9598
SessionWrapper sessionWithCredentialStorage;
99+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
100+
SessionWrapper sessionWithoutCredentialStorage;
101+
#endif
96102
SessionWrapper ephemeralStatelessSession;
97103

98104
private:

Source/CyberKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,10 @@ static void activateSessionCleanup(NetworkSessionCocoa& session, const NetworkSe
15131513
auto cookieAcceptPolicy = configuration.HTTPCookieStorage.cookieAcceptPolicy;
15141514
LOG(NetworkSession, "Created NetworkSession with cookieAcceptPolicy %lu", cookieAcceptPolicy);
15151515
RELEASE_LOG_IF(cookieAcceptPolicy == NSHTTPCookieAcceptPolicyNever, NetworkSession, "Creating network session with ID %" PRIu64 " that will not accept cookies.", m_sessionID.toUInt64());
1516+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
1517+
configuration.URLCredentialStorage = nil;
1518+
sessionSet.sessionWithoutCredentialStorage.initialize(configuration, *this, CyberCore::StoredCredentialsPolicy::DoNotUse, NavigatingToAppBoundDomain::No);
1519+
#endif
15161520
}
15171521

15181522
SessionSet& NetworkSessionCocoa::sessionSetForPage(WebPageProxyIdentifier webPageProxyID)
@@ -1538,7 +1542,11 @@ static void activateSessionCleanup(NetworkSessionCocoa& session, const NetworkSe
15381542
return ephemeralStatelessSession;
15391543

15401544
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];
1545+
#if HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
15411546
NSURLSessionConfiguration *existingConfiguration = sessionWithCredentialStorage.session.get().configuration;
1547+
#else
1548+
NSURLSessionConfiguration *existingConfiguration = sessionWithoutCredentialStorage.session.get().configuration;
1549+
#endif
15421550

15431551
configuration.HTTPCookieAcceptPolicy = NSHTTPCookieAcceptPolicyNever;
15441552
configuration.URLCredentialStorage = nil;
@@ -1582,8 +1590,13 @@ static void activateSessionCleanup(NetworkSessionCocoa& session, const NetworkSe
15821590

15831591
switch (storedCredentialsPolicy) {
15841592
case CyberCore::StoredCredentialsPolicy::Use:
1593+
return sessionSetForPage(webPageProxyID).sessionWithCredentialStorage;
15851594
case CyberCore::StoredCredentialsPolicy::DoNotUse:
1595+
#if HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
15861596
return sessionSetForPage(webPageProxyID).sessionWithCredentialStorage;
1597+
#else
1598+
return sessionSetForPage(webPageProxyID).sessionWithoutCredentialStorage;
1599+
#endif
15871600
case CyberCore::StoredCredentialsPolicy::EphemeralStateless:
15881601
return initializeEphemeralStatelessSessionIfNeeded(webPageProxyID, NavigatingToAppBoundDomain::No);
15891602
}
@@ -1597,14 +1610,26 @@ static void activateSessionCleanup(NetworkSessionCocoa& session, const NetworkSe
15971610
if (!sessionSet.appBoundSession) {
15981611
sessionSet.appBoundSession = makeUnique<IsolatedSession>();
15991612
sessionSet.appBoundSession->sessionWithCredentialStorage.initialize(sessionSet.sessionWithCredentialStorage.session.get().configuration, *this, CyberCore::StoredCredentialsPolicy::Use, NavigatingToAppBoundDomain::Yes);
1613+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
1614+
sessionSet.appBoundSession->sessionWithoutCredentialStorage.initialize(sessionSet.sessionWithoutCredentialStorage.session.get().configuration, *this, CyberCore::StoredCredentialsPolicy::DoNotUse, NavigatingToAppBoundDomain::Yes);
1615+
#endif
16001616
}
16011617

16021618
auto& sessionWrapper = [&] (auto storedCredentialsPolicy) -> SessionWrapper& {
16031619
switch (storedCredentialsPolicy) {
16041620
case CyberCore::StoredCredentialsPolicy::Use:
1621+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
1622+
LOG(NetworkSession, "Using app-bound NSURLSession with credential storage.");
1623+
return sessionSet.appBoundSession->sessionWithCredentialStorage;
1624+
#endif
16051625
case CyberCore::StoredCredentialsPolicy::DoNotUse:
1626+
#if HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
16061627
LOG(NetworkSession, "Using app-bound NSURLSession.");
16071628
return sessionSet.appBoundSession->sessionWithCredentialStorage;
1629+
#else
1630+
LOG(NetworkSession, "Using app-bound NSURLSession without credential storage.");
1631+
return sessionSet.appBoundSession->sessionWithoutCredentialStorage;
1632+
#endif
16081633
case CyberCore::StoredCredentialsPolicy::EphemeralStateless:
16091634
return initializeEphemeralStatelessSessionIfNeeded(webPageProxyID, NavigatingToAppBoundDomain::Yes);
16101635
}
@@ -1643,6 +1668,9 @@ static void activateSessionCleanup(NetworkSessionCocoa& session, const NetworkSe
16431668
auto& entry = isolatedSessions.ensure(firstPartyDomain, [this, &session, isNavigatingToAppBoundDomain] {
16441669
auto newEntry = makeUnique<IsolatedSession>();
16451670
newEntry->sessionWithCredentialStorage.initialize(sessionWithCredentialStorage.session.get().configuration, session, CyberCore::StoredCredentialsPolicy::Use, isNavigatingToAppBoundDomain);
1671+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
1672+
newEntry->sessionWithoutCredentialStorage.initialize(sessionWithoutCredentialStorage.session.get().configuration, session, CyberCore::StoredCredentialsPolicy::DoNotUse, isNavigatingToAppBoundDomain);
1673+
#endif
16461674
return newEntry;
16471675
}).iterator->value;
16481676

@@ -1651,9 +1679,18 @@ static void activateSessionCleanup(NetworkSessionCocoa& session, const NetworkSe
16511679
auto& sessionWrapper = [&] (auto storedCredentialsPolicy) -> SessionWrapper& {
16521680
switch (storedCredentialsPolicy) {
16531681
case CyberCore::StoredCredentialsPolicy::Use:
1682+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
1683+
LOG(NetworkSession, "Using app-bound NSURLSession with credential storage.");
1684+
return entry->sessionWithCredentialStorage;
1685+
#endif
16541686
case CyberCore::StoredCredentialsPolicy::DoNotUse:
1655-
LOG(NetworkSession, "Using isolated NSURLSession.");
1687+
#if HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
1688+
LOG(NetworkSession, "Using app-bound NSURLSession.");
16561689
return entry->sessionWithCredentialStorage;
1690+
#else
1691+
LOG(NetworkSession, "Using app-bound NSURLSession without credential storage.");
1692+
return entry->sessionWithoutCredentialStorage;
1693+
#endif
16571694
case CyberCore::StoredCredentialsPolicy::EphemeralStateless:
16581695
return initializeEphemeralStatelessSessionIfNeeded(isNavigatingToAppBoundDomain, session);
16591696
}
@@ -1700,19 +1737,33 @@ static void activateSessionCleanup(NetworkSessionCocoa& session, const NetworkSe
17001737
void NetworkSessionCocoa::invalidateAndCancelSessionSet(SessionSet& sessionSet)
17011738
{
17021739
[sessionSet.sessionWithCredentialStorage.session invalidateAndCancel];
1740+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
1741+
[sessionSet.sessionWithoutCredentialStorage.session invalidateAndCancel];
1742+
#endif
17031743
[sessionSet.ephemeralStatelessSession.session invalidateAndCancel];
17041744
[sessionSet.sessionWithCredentialStorage.delegate sessionInvalidated];
1745+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
1746+
[sessionSet.sessionWithoutCredentialStorage.delegate sessionInvalidated];
1747+
#endif
17051748
[sessionSet.ephemeralStatelessSession.delegate sessionInvalidated];
17061749

17071750
for (auto& session : sessionSet.isolatedSessions.values()) {
17081751
[session->sessionWithCredentialStorage.session invalidateAndCancel];
17091752
[session->sessionWithCredentialStorage.delegate sessionInvalidated];
1753+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
1754+
[session->sessionWithoutCredentialStorage.session invalidateAndCancel];
1755+
[session->sessionWithoutCredentialStorage.delegate sessionInvalidated];
1756+
#endif
17101757
}
17111758
sessionSet.isolatedSessions.clear();
17121759

17131760
if (sessionSet.appBoundSession) {
17141761
[sessionSet.appBoundSession->sessionWithCredentialStorage.session invalidateAndCancel];
17151762
[sessionSet.appBoundSession->sessionWithCredentialStorage.delegate sessionInvalidated];
1763+
#if !HAVE(NSURLSESSION_EFFECTIVE_CONFIGURATION)
1764+
[sessionSet.appBoundSession->sessionWithoutCredentialStorage.session invalidateAndCancel];
1765+
[sessionSet.appBoundSession->sessionWithoutCredentialStorage.delegate sessionInvalidated];
1766+
#endif
17161767
}
17171768
}
17181769

Source/CyberKit/Platform/spi/ios/UIKitSPI.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,12 @@ typedef NS_ENUM(NSUInteger, UIScrollPhase) {
605605
- (CGSize)_legacy_sizeWithFont:(UIFont *)font minFontSize:(CGFloat)minFontSize actualFontSize:(CGFloat *)actualFontSize forWidth:(CGFloat)width lineBreakMode:(NSLineBreakMode)lineBreakMode;
606606
@end
607607

608+
@interface UIGestureRecognizer ()
609+
#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130400
610+
@property (nonatomic, readonly) UIKeyModifierFlags _modifierFlags;
611+
#endif
612+
@end
613+
608614
@interface UITableView ()
609615
@property (nonatomic, getter=_sectionContentInsetFollowsLayoutMargins, setter=_setSectionContentInsetFollowsLayoutMargins:) BOOL sectionContentInsetFollowsLayoutMargins;
610616
@end

Source/CyberKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ static void initializeTimerCoalescingPolicy()
171171
NSMutableData.class,
172172
nil];
173173
NSError *error { nil };
174-
id result = [NSKeyedUnarchiver _strictlyUnarchivedObjectOfClasses:classes fromData:encodedData.get() error:&error];
174+
id result;
175+
if ([NSKeyedUnarchiver respondsToSelector:@selector(_strictlyUnarchivedObjectOfClasses:fromData:error:)])
176+
result = [NSKeyedUnarchiver _strictlyUnarchivedObjectOfClasses:classes fromData:encodedData.get() error:&error];
177+
else
178+
result = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:encodedData.get() error:&error];
175179
ASSERT(!error);
176180
return result;
177181
}

Source/CyberKit/UIProcess/Cocoa/ProcessAssertionCocoa.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ - (instancetype)init
127127
}];
128128

129129
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification object:[UIApplication sharedApplication] queue:nil usingBlock:^(NSNotification *) {
130+
#if HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
130131
if (![self _hasBackgroundTask])
132+
#else
133+
if (_backgroundTask == UIBackgroundTaskInvalid)
134+
#endif
131135
CyberKit::WebProcessPool::notifyProcessPoolsApplicationIsAboutToSuspend();
132136
}];
133137

@@ -197,7 +201,11 @@ - (BOOL)_hasBackgroundTask
197201

198202
- (void)_updateBackgroundTask
199203
{
204+
#if HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
200205
if (!_assertionsNeedingBackgroundTask.isEmptyIgnoringNullReferences() && (![self _hasBackgroundTask] || _backgroundTaskWasInvalidated)) {
206+
#else
207+
if (!_assertionsNeedingBackgroundTask.isEmptyIgnoringNullReferences() && (_backgroundTask == UIBackgroundTaskInvalid || _backgroundTaskWasInvalidated)) {
208+
#endif
201209
if (processHasActiveRunTimeLimitation()) {
202210
RELEASE_LOG(ProcessSuspension, "%p - WKProcessAssertionBackgroundTaskManager: Ignored request to start a new background task because RunningBoard has already started the expiration timer", self);
203211
return;
@@ -278,7 +286,11 @@ - (void)_handleBackgroundTaskExpirationOnMainThread
278286

279287
- (void)_releaseBackgroundTask
280288
{
289+
#if HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
281290
if (![self _hasBackgroundTask])
291+
#else
292+
if (_backgroundTask == UIBackgroundTaskInvalid)
293+
#endif
282294
return;
283295

284296
RELEASE_LOG(ProcessSuspension, "%p - WKProcessAssertionBackgroundTaskManager: endBackgroundTask", self);
@@ -405,6 +417,7 @@ static BKSProcessAssertionFlags flagsForAssertionType(ProcessAssertionType asser
405417
case ProcessAssertionType::MediaPlayback:
406418
return foregroundTabFlags;
407419
case ProcessAssertionType::FinishTaskInterruptable:
420+
return backgroundTabFlags;
408421
case ProcessAssertionType::BoostedJetsam:
409422
ASSERT_NOT_REACHED();
410423
return 0;
@@ -423,6 +436,7 @@ static BKSProcessAssertionReason toBKSProcessAssertionReason(ProcessAssertionTyp
423436
case ProcessAssertionType::MediaPlayback:
424437
return BKSProcessAssertionReasonMediaPlayback;
425438
case ProcessAssertionType::FinishTaskInterruptable:
439+
return BKSProcessAssertionReasonFinishTask;
426440
case ProcessAssertionType::BoostedJetsam:
427441
ASSERT_NOT_REACHED();
428442
return 0;

0 commit comments

Comments
 (0)