Title: [288451] trunk/Source
Revision
288451
Author
[email protected]
Date
2022-01-24 09:44:12 -0800 (Mon, 24 Jan 2022)

Log Message

Simplify accesses to SystemVersion.plist
https://bugs.webkit.org/show_bug.cgi?id=234306

Reviewed by Alexey Proskuryakov.

Source/WebCore:

No new tests since no behavior change is expected.

* platform/cocoa/SystemVersion.mm:
(WebCore::createSystemMarketingVersion):
    Read the SystemVersion.plist file using _CFCopySystemVersionDictionary()
    rather than by manually constructing the path and initializing the dictionary.

Source/WebCore/PAL:

* pal/spi/cf/CFUtilitiesSPI.h:
    Forward declare _kCFSystemVersionProductUserVisibleVersionKey, used
    by WebCore's SystemVersion.mm

Source/WebKit:

No new tests since no behavior change is expected.

* UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:
(WebKit::WebInspectorUIProxy::infoForLocalDebuggable):
    Use _CFCopySystemVersionDictionary() to locate and load the
    SystemVersion.plist file rather than doing that all manually.
(WebKit::systemVersionPlist): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288450 => 288451)


--- trunk/Source/WebCore/ChangeLog	2022-01-24 17:38:07 UTC (rev 288450)
+++ trunk/Source/WebCore/ChangeLog	2022-01-24 17:44:12 UTC (rev 288451)
@@ -1,3 +1,17 @@
+2022-01-24  David Quesada  <[email protected]>
+
+        Simplify accesses to SystemVersion.plist
+        https://bugs.webkit.org/show_bug.cgi?id=234306
+
+        Reviewed by Alexey Proskuryakov.
+
+        No new tests since no behavior change is expected.
+
+        * platform/cocoa/SystemVersion.mm:
+        (WebCore::createSystemMarketingVersion):
+            Read the SystemVersion.plist file using _CFCopySystemVersionDictionary()
+            rather than by manually constructing the path and initializing the dictionary.
+
 2022-01-24  Rob Buis  <[email protected]>
 
         Remove customElements when transitioning documents

Modified: trunk/Source/WebCore/PAL/ChangeLog (288450 => 288451)


--- trunk/Source/WebCore/PAL/ChangeLog	2022-01-24 17:38:07 UTC (rev 288450)
+++ trunk/Source/WebCore/PAL/ChangeLog	2022-01-24 17:44:12 UTC (rev 288451)
@@ -1,3 +1,14 @@
+2022-01-24  David Quesada  <[email protected]>
+
+        Simplify accesses to SystemVersion.plist
+        https://bugs.webkit.org/show_bug.cgi?id=234306
+
+        Reviewed by Alexey Proskuryakov.
+
+        * pal/spi/cf/CFUtilitiesSPI.h:
+            Forward declare _kCFSystemVersionProductUserVisibleVersionKey, used
+            by WebCore's SystemVersion.mm
+
 2022-01-21  Sihui Liu  <[email protected]>
 
         Disable CFURLCache in WebKit2

Modified: trunk/Source/WebCore/PAL/pal/spi/cf/CFUtilitiesSPI.h (288450 => 288451)


--- trunk/Source/WebCore/PAL/pal/spi/cf/CFUtilitiesSPI.h	2022-01-24 17:38:07 UTC (rev 288450)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFUtilitiesSPI.h	2022-01-24 17:44:12 UTC (rev 288451)
@@ -49,6 +49,7 @@
 extern const CFStringRef kCFWebServicesProviderDefaultDisplayNameKey;
 extern const CFStringRef kCFWebServicesTypeWebSearch;
 extern const CFStringRef _kCFSystemVersionBuildVersionKey;
+extern const CFStringRef _kCFSystemVersionProductUserVisibleVersionKey;
 extern const CFStringRef _kCFSystemVersionProductVersionKey;
 
 Boolean _CFAppVersionCheckLessThan(CFStringRef bundleID, int linkedOnAnOlderSystemThan, double versionNumberLessThan);

Modified: trunk/Source/WebCore/platform/cocoa/SystemVersion.mm (288450 => 288451)


--- trunk/Source/WebCore/platform/cocoa/SystemVersion.mm	2022-01-24 17:38:07 UTC (rev 288450)
+++ trunk/Source/WebCore/platform/cocoa/SystemVersion.mm	2022-01-24 17:44:12 UTC (rev 288451)
@@ -24,6 +24,7 @@
 
 #import "config.h"
 #import "SystemVersion.h"
+#import <pal/spi/cf/CFUtilitiesSPI.h>
 
 namespace WebCore {
 
@@ -30,14 +31,9 @@
 static RetainPtr<NSString> createSystemMarketingVersion()
 {
     // Can't use -[NSProcessInfo operatingSystemVersionString] because it has too much stuff we don't want.
-    NSString *systemLibraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES) objectAtIndex:0];
-#if PLATFORM(IOS_FAMILY_SIMULATOR)
-    if (char *simulatorRoot = getenv("SIMULATOR_ROOT"))
-        systemLibraryPath = [NSString stringWithFormat:@"%s/%@", simulatorRoot, systemLibraryPath];
-#endif
-    NSString *systemVersionPlistPath = [systemLibraryPath stringByAppendingPathComponent:@"CoreServices/SystemVersion.plist"];
-    NSDictionary *systemVersionInfo = [NSDictionary dictionaryWithContentsOfFile:systemVersionPlistPath];
-    return adoptNS([[systemVersionInfo objectForKey:@"ProductVersion"] copy]);
+    auto systemVersionDictionary = adoptCF(_CFCopySystemVersionDictionary());
+    CFStringRef productVersion = static_cast<CFStringRef>(CFDictionaryGetValue(systemVersionDictionary.get(), _kCFSystemVersionProductVersionKey));
+    return adoptNS([(__bridge NSString *)productVersion copy]);
 }
 
 NSString *systemMarketingVersion()

Modified: trunk/Source/WebKit/ChangeLog (288450 => 288451)


--- trunk/Source/WebKit/ChangeLog	2022-01-24 17:38:07 UTC (rev 288450)
+++ trunk/Source/WebKit/ChangeLog	2022-01-24 17:44:12 UTC (rev 288451)
@@ -1,3 +1,18 @@
+2022-01-24  David Quesada  <[email protected]>
+
+        Simplify accesses to SystemVersion.plist
+        https://bugs.webkit.org/show_bug.cgi?id=234306
+
+        Reviewed by Alexey Proskuryakov.
+
+        No new tests since no behavior change is expected.
+
+        * UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:
+        (WebKit::WebInspectorUIProxy::infoForLocalDebuggable):
+            Use _CFCopySystemVersionDictionary() to locate and load the
+            SystemVersion.plist file rather than doing that all manually.
+        (WebKit::systemVersionPlist): Deleted.
+
 2022-01-24  Said Abou-Hallawa  <[email protected]>
 
         [GPU Process] [Filters] Move FEImage to the 'platform' directory

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm (288450 => 288451)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm	2022-01-24 17:38:07 UTC (rev 288450)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm	2022-01-24 17:44:12 UTC (rev 288451)
@@ -48,6 +48,7 @@
 #import <WebCore/CertificateInfo.h>
 #import <WebCore/InspectorFrontendClientLocal.h>
 #import <WebCore/LocalizedStrings.h>
+#import <pal/spi/cf/CFUtilitiesSPI.h>
 #import <wtf/text/Base64.h>
 
 static const NSUInteger windowStyleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable | NSWindowStyleMaskFullSizeContentView;
@@ -787,23 +788,15 @@
     return [WKInspectorViewController URLForInspectorResource:@"Test.html"].absoluteString;
 }
 
-static NSDictionary *systemVersionPlist()
-{
-    NSString *systemLibraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES) objectAtIndex:0];
-    NSString *systemVersionPlistPath = [systemLibraryPath stringByAppendingPathComponent:@"CoreServices/SystemVersion.plist"];
-    NSDictionary *systemVersionInfo = [NSDictionary dictionaryWithContentsOfFile:systemVersionPlistPath];
-    return systemVersionInfo;
-}
-
 DebuggableInfoData WebInspectorUIProxy::infoForLocalDebuggable()
 {
-    NSDictionary *plist = systemVersionPlist();
+    NSDictionary *plist = adoptCF(_CFCopySystemVersionDictionary()).bridgingAutorelease();
 
     DebuggableInfoData result;
     result.debuggableType = Inspector::DebuggableType::WebPage;
     result.targetPlatformName = "macOS"_s;
-    result.targetBuildVersion = plist[@"ProductBuildVersion"];
-    result.targetProductVersion = plist[@"ProductUserVisibleVersion"];
+    result.targetBuildVersion = plist[static_cast<NSString *>(_kCFSystemVersionBuildVersionKey)];
+    result.targetProductVersion = plist[static_cast<NSString *>(_kCFSystemVersionProductUserVisibleVersionKey)];
     result.targetIsSimulator = false;
 
     return result;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to