Title: [212134] trunk
Revision
212134
Author
beid...@apple.com
Date
2017-02-10 12:38:35 -0800 (Fri, 10 Feb 2017)

Log Message

Replace all WebKit Library Version checks in WK2 with SDK version checks.
https://bugs.webkit.org/show_bug.cgi?id=168124

Reviewed by Geoffrey Garen.

Source/WebKit2:

This change gets rid of WebKit Library Version checks and replaces them with SDK version checks.

To allow our tools to still be able to test new behaviors even when built against older SDKs,
it also opts them into an SPI default to have "linkedOnOrAfter()" always return true.

* Shared/Cocoa/CompletionHandlerCallChecker.mm:
(WebKit::shouldThrowExceptionForDuplicateCompletionHandlerCall):

* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):

* UIProcess/Cocoa/VersionChecks.h:
(WebKit::linkedOnOrAfter): Deleted.
* UIProcess/Cocoa/VersionChecks.mm:
(WebKit::linkedOnOrAfter):

* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::isNetworkCacheEnabled):

Tools:

For each of our tools that use WebKit2, opt them in to the new linkedOnOrAfter(Everything) setting.

* MiniBrowser/mac/main.m:
(main):
* MobileMiniBrowser/MobileMiniBrowser/main.m:
(main):
* TestWebKitAPI/ios/mainIOS.mm:
(main):
* TestWebKitAPI/mac/mainMac.mm:
(main):
* WebKitTestRunner/ios/mainIOS.mm:
(main):
* WebKitTestRunner/mac/main.mm:
(setDefaultsToConsistentValuesForTesting):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (212133 => 212134)


--- trunk/Source/WebKit2/ChangeLog	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-10 20:38:35 UTC (rev 212134)
@@ -1,3 +1,29 @@
+2017-02-10  Brady Eidson  <beid...@apple.com>
+
+        Replace all WebKit Library Version checks in WK2 with SDK version checks.
+        https://bugs.webkit.org/show_bug.cgi?id=168124
+
+        Reviewed by Geoffrey Garen.
+
+        This change gets rid of WebKit Library Version checks and replaces them with SDK version checks.
+        
+        To allow our tools to still be able to test new behaviors even when built against older SDKs,
+        it also opts them into an SPI default to have "linkedOnOrAfter()" always return true.
+        
+        * Shared/Cocoa/CompletionHandlerCallChecker.mm:
+        (WebKit::shouldThrowExceptionForDuplicateCompletionHandlerCall):
+        
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]):
+        
+        * UIProcess/Cocoa/VersionChecks.h:
+        (WebKit::linkedOnOrAfter): Deleted.
+        * UIProcess/Cocoa/VersionChecks.mm:
+        (WebKit::linkedOnOrAfter):
+        
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::isNetworkCacheEnabled):
+
 2017-02-10  Brian Burg  <bb...@apple.com>
 
         [Cocoa] Web Inspector: generate an NS_ENUM containing platforms supported by the protocol code generator

Modified: trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.mm (212133 => 212134)


--- trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.mm	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.mm	2017-02-10 20:38:35 UTC (rev 212134)
@@ -67,7 +67,7 @@
     static bool shouldThrowException;
     static std::once_flag once;
     std::call_once(once, [] {
-        shouldThrowException = linkedOnOrAfter<FirstWebKitWithExceptionsForDuplicateCompletionHandlerCalls>();
+        shouldThrowException = linkedOnOrAfter(SDKVersion::FirstWithExceptionsForDuplicateCompletionHandlerCalls);
     });
     return shouldThrowException;
 }

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (212133 => 212134)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2017-02-10 20:38:35 UTC (rev 212134)
@@ -145,7 +145,7 @@
     _inlineMediaPlaybackRequiresPlaysInlineAttribute = !_allowsInlineMediaPlayback;
     _allowsInlineMediaPlaybackAfterFullscreen = !_allowsInlineMediaPlayback;
     _mediaDataLoadsAutomatically = NO;
-    if (WebKit::linkedOnOrAfter<WebKit::FirstWebKitWithMediaTypesRequiringUserActionForPlayback>())
+    if (WebKit::linkedOnOrAfter(WebKit::SDKVersion::FirstWithMediaTypesRequiringUserActionForPlayback))
         _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAudio;
     else
         _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h (212133 => 212134)


--- trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h	2017-02-10 20:38:35 UTC (rev 212134)
@@ -29,47 +29,17 @@
 
 namespace WebKit {
 
-/*
-    Version numbers are based on the 'current library version' specified in the WebKit build rules.
-    All of these methods return or take version numbers with each part shifted to the left 2 bytes.
-    For example the version 1.2.3 is returned as 0x00010203 and version 200.3.5 is returned as 0x00C80305
-    A version of -1 is returned if the main executable did not link against WebKit.
-
-    Use the current WebKit version number, available in WebKit2/Configurations/Version.xcconfig,
-    when adding a new version constant.
-*/
-
-struct FirstWebKitWithNetworkCache {
-    static const int LibraryVersion { 0x02590116 }; // 601.1.22
+enum class SDKVersion : uint32_t {
 #if PLATFORM(IOS)
-    static const uint32_t SDKVersion { DYLD_IOS_VERSION_9_0 };
+    FirstWithNetworkCache = DYLD_IOS_VERSION_9_0,
+    FirstWithMediaTypesRequiringUserActionForPlayback = DYLD_IOS_VERSION_10_0,
+    FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_IOS_VERSION_10_3,
 #elif PLATFORM(MAC)
-    static const uint32_t SDKVersion { DYLD_MACOSX_VERSION_10_11 };
+    FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
+    FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_MACOSX_VERSION_10_12_4,
 #endif
 };
 
-struct FirstWebKitWithMediaTypesRequiringUserActionForPlayback {
-    static const int LibraryVersion { 0x025A0121 }; // 602.1.33
-#if PLATFORM(IOS)
-    static const uint32_t SDKVersion { DYLD_IOS_VERSION_10_0 };
-#elif PLATFORM(MAC)
-    static const uint32_t SDKVersion { DYLD_MACOSX_VERSION_10_12 };
-#endif
-};
+bool linkedOnOrAfter(SDKVersion);
 
-struct FirstWebKitWithExceptionsForDuplicateCompletionHandlerCalls {
-    static const int LibraryVersion { 0x025B0111 }; // 603.1.17
-#if PLATFORM(IOS)
-    static const uint32_t SDKVersion { DYLD_IOS_VERSION_10_3 };
-#elif PLATFORM(MAC)
-    static const uint32_t SDKVersion { DYLD_MACOSX_VERSION_10_12_4 };
-#endif
-};
-
-bool linkedOnOrAfter(int libraryVersion, uint32_t sdkVersion);
-template <typename VersionInfo> bool linkedOnOrAfter()
-{
-    return linkedOnOrAfter(VersionInfo::LibraryVersion, VersionInfo::SDKVersion);
 }
-
-}

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.mm (212133 => 212134)


--- trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.mm	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.mm	2017-02-10 20:38:35 UTC (rev 212134)
@@ -26,31 +26,33 @@
 #import "config.h"
 #import "VersionChecks.h"
 
+#import <WebCore/RuntimeApplicationChecks.h>
 #import <mach-o/dyld.h>
+#import <mutex>
 
-#if PLATFORM(IOS)
-#import <WebCore/RuntimeApplicationChecks.h>
-#endif
-
 namespace WebKit {
 
-bool linkedOnOrAfter(int libraryVersion, uint32_t sdkVersion)
+static NSString * const WebKitLinkedOnOrAfterEverythingKey = @"WebKitLinkedOnOrAfterEverything";
+
+bool linkedOnOrAfter(SDKVersion sdkVersion)
 {
+     static bool linkedOnOrAfterEverything;
+     static std::once_flag once;
+     std::call_once(once, [] {
+        bool isSafari = false;
 #if PLATFORM(IOS)
-    // Always make new features available for Safari.
-    if (WebCore::IOSApplication::isMobileSafari())
-        return true;
+        if (WebCore::IOSApplication::isMobileSafari())
+            isSafari = true;
+#elif PLATFORM(MAC)
+        if (WebCore::MacApplication::isSafari())
+            isSafari = true;
 #endif
 
-    // If the app was build against a new enough SDK, it definitely passes the linked-on-or-after check.
-    if (dyld_get_program_sdk_version() >= sdkVersion)
-        return true;
+        if (isSafari || [[NSUserDefaults standardUserDefaults] boolForKey:WebKitLinkedOnOrAfterEverythingKey])
+            linkedOnOrAfterEverything = true;
+    });
 
-    // If the app was built against an older SDK, we might still consider it linked-on-or-after
-    // by checking the linked WebKit library version number, if one exists.
-
-    int linkedVersion = NSVersionOfLinkTimeLibrary("WebKit");
-    return linkedVersion == -1 ? false : linkedVersion >= libraryVersion;
+    return linkedOnOrAfterEverything ? true : dyld_get_program_sdk_version() >= static_cast<uint32_t>(sdkVersion);
 }
 
 }

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm (212133 => 212134)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2017-02-10 20:38:35 UTC (rev 212134)
@@ -462,7 +462,7 @@
 
     bool networkCacheEnabledByDefaults = [defaults boolForKey:WebKitNetworkCacheEnabledDefaultsKey];
 
-    return networkCacheEnabledByDefaults && linkedOnOrAfter<FirstWebKitWithNetworkCache>();
+    return networkCacheEnabledByDefaults && linkedOnOrAfter(SDKVersion::FirstWithNetworkCache);
 #else
     return false;
 #endif

Modified: trunk/Tools/ChangeLog (212133 => 212134)


--- trunk/Tools/ChangeLog	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Tools/ChangeLog	2017-02-10 20:38:35 UTC (rev 212134)
@@ -1,3 +1,25 @@
+2017-02-10  Brady Eidson  <beid...@apple.com>
+
+        Replace all WebKit Library Version checks in WK2 with SDK version checks.
+        https://bugs.webkit.org/show_bug.cgi?id=168124
+
+        Reviewed by Geoffrey Garen.
+
+        For each of our tools that use WebKit2, opt them in to the new linkedOnOrAfter(Everything) setting.
+        
+        * MiniBrowser/mac/main.m:
+        (main):
+        * MobileMiniBrowser/MobileMiniBrowser/main.m:
+        (main):
+        * TestWebKitAPI/ios/mainIOS.mm:
+        (main):
+        * TestWebKitAPI/mac/mainMac.mm:
+        (main):
+        * WebKitTestRunner/ios/mainIOS.mm:
+        (main):
+        * WebKitTestRunner/mac/main.mm:
+        (setDefaultsToConsistentValuesForTesting):
+
 2017-02-10  Alex Christensen  <achristen...@webkit.org>
 
         Fix El Capitan build.

Modified: trunk/Tools/MiniBrowser/mac/main.m (212133 => 212134)


--- trunk/Tools/MiniBrowser/mac/main.m	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Tools/MiniBrowser/mac/main.m	2017-02-10 20:38:35 UTC (rev 212134)
@@ -27,5 +27,7 @@
 
 int main(int argc, char *argv[])
 {
+    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitLinkedOnOrAfterEverything"];
+
     return NSApplicationMain(argc,  (const char **) argv);
 }

Modified: trunk/Tools/MobileMiniBrowser/MobileMiniBrowser/main.m (212133 => 212134)


--- trunk/Tools/MobileMiniBrowser/MobileMiniBrowser/main.m	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Tools/MobileMiniBrowser/MobileMiniBrowser/main.m	2017-02-10 20:38:35 UTC (rev 212134)
@@ -27,6 +27,8 @@
 
 int main(int argc, char * argv[])
 {
+    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitLinkedOnOrAfterEverything"];
+
     @autoreleasepool {
         return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
     }

Modified: trunk/Tools/TestWebKitAPI/ios/mainIOS.mm (212133 => 212134)


--- trunk/Tools/TestWebKitAPI/ios/mainIOS.mm	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Tools/TestWebKitAPI/ios/mainIOS.mm	2017-02-10 20:38:35 UTC (rev 212134)
@@ -31,6 +31,19 @@
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
     [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:@"TestWebKitAPI"];
+
+    // Set up user defaults.
+    NSMutableDictionary *argumentDomain = [[[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain] mutableCopy];
+    if (!argumentDomain)
+        argumentDomain = [[NSMutableDictionary alloc] init];
+    
+    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+                          [NSNumber numberWithBool:YES],    @"WebKitLinkedOnOrAfterEverything",
+                          nil];
+
+    [argumentDomain addEntriesFromDictionary:dict];
+    [[NSUserDefaults standardUserDefaults] setVolatileDomain:argumentDomain forName:NSArgumentDomain];
+
     bool passed = TestWebKitAPI::TestsController::singleton().run(argc, argv);
 
     [pool drain];

Modified: trunk/Tools/TestWebKitAPI/mac/mainMac.mm (212133 => 212134)


--- trunk/Tools/TestWebKitAPI/mac/mainMac.mm	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Tools/TestWebKitAPI/mac/mainMac.mm	2017-02-10 20:38:35 UTC (rev 212134)
@@ -34,6 +34,18 @@
 
     [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:@"TestWebKitAPI"];
 
+    // Set a user default for TestWebKitAPI to bypass all linked-on-or-after checks in WebKit
+    NSMutableDictionary *argumentDomain = [[[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain] mutableCopy];
+    if (!argumentDomain)
+        argumentDomain = [[NSMutableDictionary alloc] init];
+    
+    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+                          [NSNumber numberWithBool:YES],    @"WebKitLinkedOnOrAfterEverything",
+                          nil];
+
+    [argumentDomain addEntriesFromDictionary:dict];
+    [[NSUserDefaults standardUserDefaults] setVolatileDomain:argumentDomain forName:NSArgumentDomain];
+
     [NSApplication sharedApplication];
     _BeginEventReceiptOnThread(); // Makes window visibility notifications work (and possibly more).
 

Modified: trunk/Tools/WebKitTestRunner/ios/mainIOS.mm (212133 => 212134)


--- trunk/Tools/WebKitTestRunner/ios/mainIOS.mm	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Tools/WebKitTestRunner/ios/mainIOS.mm	2017-02-10 20:38:35 UTC (rev 212134)
@@ -67,6 +67,8 @@
     _argc = argc;
     _argv = argv;
 
+    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitLinkedOnOrAfterEverything"];
+
     UIApplicationMain(argc, (char**)argv, @"WebKitTestRunnerApp", @"WebKitTestRunnerApp");
     return 0;
 }

Modified: trunk/Tools/WebKitTestRunner/mac/main.mm (212133 => 212134)


--- trunk/Tools/WebKitTestRunner/mac/main.mm	2017-02-10 20:35:59 UTC (rev 212133)
+++ trunk/Tools/WebKitTestRunner/mac/main.mm	2017-02-10 20:38:35 UTC (rev 212134)
@@ -41,6 +41,7 @@
         @"AppleEnableSwipeNavigateWithScrolls": @YES,
         @"com.apple.swipescrolldirection": @1,
         @"com.apple.trackpad.forceClick": @1,
+        @"WebKitLinkedOnOrAfterEverything": @YES,
     };
 
     [[NSUserDefaults standardUserDefaults] setValuesForKeysWithDictionary:dict];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to