Title: [287697] trunk/Source/WebCore
Revision
287697
Author
[email protected]
Date
2022-01-06 10:04:00 -0800 (Thu, 06 Jan 2022)

Log Message

Prevent reentrancy in -[WebCoreThemeView window]
https://bugs.webkit.org/show_bug.cgi?id=234258
<rdar://85927756>

Reviewed by Wenson Hsieh.

Prevent reentrancy in `-[WebCoreThemeView window]` by eagerly
initializing the window (when `WebCoreThemeView` is created).

`WebCoreThemeView` is already only created once per process (as a
static variable in `ThemeMac::ensuredView`), so a static variable
for the window is unnecessary.

* platform/mac/ThemeMac.mm:
(-[WebCoreThemeView init]):
(-[WebCoreThemeView window]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287696 => 287697)


--- trunk/Source/WebCore/ChangeLog	2022-01-06 17:51:41 UTC (rev 287696)
+++ trunk/Source/WebCore/ChangeLog	2022-01-06 18:04:00 UTC (rev 287697)
@@ -1,3 +1,22 @@
+2022-01-06  Aditya Keerthi  <[email protected]>
+
+        Prevent reentrancy in -[WebCoreThemeView window]
+        https://bugs.webkit.org/show_bug.cgi?id=234258
+        <rdar://85927756>
+
+        Reviewed by Wenson Hsieh.
+
+        Prevent reentrancy in `-[WebCoreThemeView window]` by eagerly
+        initializing the window (when `WebCoreThemeView` is created).
+
+        `WebCoreThemeView` is already only created once per process (as a
+        static variable in `ThemeMac::ensuredView`), so a static variable
+        for the window is unnecessary.
+
+        * platform/mac/ThemeMac.mm:
+        (-[WebCoreThemeView init]):
+        (-[WebCoreThemeView window]):
+
 2022-01-06  Chris Dumez  <[email protected]>
 
         Drop implementation for COOP / COEP violation reporting

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (287696 => 287697)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2022-01-06 17:51:41 UTC (rev 287696)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2022-01-06 18:04:00 UTC (rev 287697)
@@ -68,17 +68,27 @@
 }
 @end
 
-@implementation WebCoreThemeView
+@implementation WebCoreThemeView {
+    RetainPtr<WebCoreThemeWindow> _window;
+}
 
-- (NSWindow *)window
+- (instancetype)init
 {
+    if (!(self = [super init]))
+        return nil;
+
     // Using defer:YES prevents us from wasting any window server resources for this window, since we're not actually
     // going to draw into it. The other arguments match what you get when calling -[NSWindow init].
-    static WebCoreThemeWindow *window = [[WebCoreThemeWindow alloc] initWithContentRect:NSMakeRect(100, 100, 100, 100)
-        styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES];
-    return window;
+    _window = adoptNS([[WebCoreThemeWindow alloc] initWithContentRect:NSMakeRect(100, 100, 100, 100) styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES]);
+
+    return self;
 }
 
+- (NSWindow *)window
+{
+    return _window.get();
+}
+
 - (BOOL)isFlipped
 {
     return YES;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to