Title: [246726] trunk/Source/WebKit
Revision
246726
Author
[email protected]
Date
2019-06-23 20:44:50 -0700 (Sun, 23 Jun 2019)

Log Message

Platform font class gets needlessly initialized in the Networking process
https://bugs.webkit.org/show_bug.cgi?id=199140

Reviewed by Tim Horton.

* NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in: Revert a change that was made in
  r246702, which is not needed anymore.
* Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb: Ditto.

* Shared/Cocoa/ArgumentCodersCocoa.mm:
(IPC::platformColorClass): Added getter that uses NSClassFromString, thereby avoiding
  initializing the class.
(IPC::platformFontClass): Ditto.
(IPC::typeFromObject): Changed to use the above getters instead of +class.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (246725 => 246726)


--- trunk/Source/WebKit/ChangeLog	2019-06-24 03:09:40 UTC (rev 246725)
+++ trunk/Source/WebKit/ChangeLog	2019-06-24 03:44:50 UTC (rev 246726)
@@ -1,3 +1,20 @@
+2019-06-23  Dan Bernstein  <[email protected]>
+
+        Platform font class gets needlessly initialized in the Networking process
+        https://bugs.webkit.org/show_bug.cgi?id=199140
+
+        Reviewed by Tim Horton.
+
+        * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in: Revert a change that was made in
+          r246702, which is not needed anymore.
+        * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb: Ditto.
+
+        * Shared/Cocoa/ArgumentCodersCocoa.mm:
+        (IPC::platformColorClass): Added getter that uses NSClassFromString, thereby avoiding
+          initializing the class.
+        (IPC::platformFontClass): Ditto.
+        (IPC::typeFromObject): Changed to use the above getters instead of +class.
+
 2019-06-23  Simon Fraser  <[email protected]>
 
         [Async overflow scroll] Clipped composited layers inside overflow scroll jitter and get incorrectly clipped

Modified: trunk/Source/WebKit/NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in (246725 => 246726)


--- trunk/Source/WebKit/NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in	2019-06-24 03:09:40 UTC (rev 246725)
+++ trunk/Source/WebKit/NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in	2019-06-24 03:44:50 UTC (rev 246726)
@@ -95,7 +95,6 @@
 
 (allow file-read*
     ;; Basic system paths
-    (subpath "/Library/Fonts") ;; Needed to serialize font data types <rdar://problem/50164879>
     (subpath "/Library/Frameworks")
     (subpath "/Library/Managed Preferences")
 

Modified: trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb (246725 => 246726)


--- trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb	2019-06-24 03:09:40 UTC (rev 246725)
+++ trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb	2019-06-24 03:44:50 UTC (rev 246726)
@@ -72,12 +72,6 @@
     (literal "/usr/local/lib/log") ; <rdar://problem/36629495>
 )
 
-;; Read-only preferences and data
-(allow file-read*
-    ;; Basic system paths
-    (subpath "/Library/Fonts") ;; Needed to serialize font data types <rdar://problem/50164879>
-)
-
 ;; Security framework
 (allow mach-lookup
     (global-name "com.apple.ocspd")

Modified: trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm (246725 => 246726)


--- trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm	2019-06-24 03:09:40 UTC (rev 246725)
+++ trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm	2019-06-24 03:44:50 UTC (rev 246726)
@@ -77,6 +77,34 @@
 
 #pragma mark - Helpers
 
+static Class platformColorClass()
+{
+    static Class colorClass;
+    static std::once_flag flag;
+    std::call_once(flag, [] {
+#if USE(APPKIT)
+        colorClass = NSClassFromString(@"NSColor");
+#else
+        colorClass = NSClassFromString(@"UIColor");
+#endif
+    });
+    return colorClass;
+}
+
+static Class platformFontClass()
+{
+    static Class fontClass;
+    static std::once_flag flag;
+    std::call_once(flag, [] {
+#if USE(APPKIT)
+        fontClass = NSClassFromString(@"NSFont");
+#else
+        fontClass = NSClassFromString(@"UIFont");
+#endif
+    });
+    return fontClass;
+}
+
 static NSType typeFromObject(id object)
 {
     ASSERT(object);
@@ -84,7 +112,7 @@
     // Specific classes handled.
     if ([object isKindOfClass:[NSArray class]])
         return NSType::Array;
-    if ([object isKindOfClass:[PlatformColor class]])
+    if ([object isKindOfClass:platformColorClass()])
         return NSType::Color;
     if ([object isKindOfClass:[NSData class]])
         return NSType::Data;
@@ -92,7 +120,7 @@
         return NSType::Date;
     if ([object isKindOfClass:[NSDictionary class]])
         return NSType::Dictionary;
-    if ([object isKindOfClass:[PlatformFont class]])
+    if ([object isKindOfClass:platformFontClass()])
         return NSType::Font;
     if ([object isKindOfClass:[NSNumber class]])
         return NSType::Number;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to