Title: [228243] trunk/Source/WebCore
Revision
228243
Author
[email protected]
Date
2018-02-07 14:33:10 -0800 (Wed, 07 Feb 2018)

Log Message

Assert that NSApp is not running in the WebProcess.
https://bugs.webkit.org/show_bug.cgi?id=182553
<rdar://problem/37316144>
        
Reviewed by Simon Fraser.

In WebCore, there are a few places where NSApp is referenced. Since the WebContent process
is no longer using the NSApplication run loop, and NSApp is no longer guaranteed to be
valid, we should make sure that the NSApp is not referenced by the WebContent process or
the Network process, by asserting that the NSApplication event loop is running when NSApp
is referenced. It is still ok for the UIProcess to reference NSApp. Adding these assert
will help catch references to NSApp when the NSApplication run loop is not used.
Also, do not post a fake mouse event in PasteBoard::setDragImage when the NSApplication
run loop is not running, since this is only relevant in WK1.

No new tests, covered by existing tests. 

* page/mac/EventHandlerMac.mm:
(WebCore::lastEventIsMouseUp):
(WebCore::EventHandler::sendFakeEventsAfterWidgetTracking):
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::setDragImage):
* platform/mac/WebVideoFullscreenController.mm:
(-[WebVideoFullscreenController windowDidLoad]):
(-[WebVideoFullscreenController updateMenuAndDockForFullscreen]):
* platform/mac/WebWindowAnimation.mm:
(WebCore::WebWindowAnimationDurationFromDuration):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228242 => 228243)


--- trunk/Source/WebCore/ChangeLog	2018-02-07 22:02:55 UTC (rev 228242)
+++ trunk/Source/WebCore/ChangeLog	2018-02-07 22:33:10 UTC (rev 228243)
@@ -1,3 +1,33 @@
+2018-02-07  Per Arne Vollan  <[email protected]>
+
+        Assert that NSApp is not running in the WebProcess.
+        https://bugs.webkit.org/show_bug.cgi?id=182553
+        <rdar://problem/37316144>
+        
+        Reviewed by Simon Fraser.
+
+        In WebCore, there are a few places where NSApp is referenced. Since the WebContent process
+        is no longer using the NSApplication run loop, and NSApp is no longer guaranteed to be
+        valid, we should make sure that the NSApp is not referenced by the WebContent process or
+        the Network process, by asserting that the NSApplication event loop is running when NSApp
+        is referenced. It is still ok for the UIProcess to reference NSApp. Adding these assert
+        will help catch references to NSApp when the NSApplication run loop is not used.
+        Also, do not post a fake mouse event in PasteBoard::setDragImage when the NSApplication
+        run loop is not running, since this is only relevant in WK1.
+
+        No new tests, covered by existing tests. 
+
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::lastEventIsMouseUp):
+        (WebCore::EventHandler::sendFakeEventsAfterWidgetTracking):
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::Pasteboard::setDragImage):
+        * platform/mac/WebVideoFullscreenController.mm:
+        (-[WebVideoFullscreenController windowDidLoad]):
+        (-[WebVideoFullscreenController updateMenuAndDockForFullscreen]):
+        * platform/mac/WebWindowAnimation.mm:
+        (WebCore::WebWindowAnimationDurationFromDuration):
+
 2018-02-07  Youenn Fablet  <[email protected]>
 
         ASSERTION FAILED: m_timeOrigin in Performance::Performance()

Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (228242 => 228243)


--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2018-02-07 22:02:55 UTC (rev 228242)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2018-02-07 22:33:10 UTC (rev 228243)
@@ -196,6 +196,8 @@
     // that state. Handling this was critical when we used AppKit widgets for form elements.
     // It's not clear in what cases this is helpful now -- it's possible it can be removed. 
 
+    ASSERT([NSApp isRunning]);
+
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     NSEvent *currentEventAfterHandlingMouseDown = [NSApp currentEvent];
     return EventHandler::currentNSEvent() != currentEventAfterHandlingMouseDown
@@ -570,6 +572,7 @@
     m_sendingEventToSubview = false;
     int eventType = [initiatingEvent type];
     if (eventType == NSEventTypeLeftMouseDown || eventType == NSEventTypeKeyDown) {
+        ASSERT([NSApp isRunning]);
         NSEvent *fakeEvent = nil;
         if (eventType == NSEventTypeLeftMouseDown) {
             fakeEvent = [NSEvent mouseEventWithType:NSEventTypeLeftMouseUp

Modified: trunk/Source/WebCore/platform/mac/EventLoopMac.mm (228242 => 228243)


--- trunk/Source/WebCore/platform/mac/EventLoopMac.mm	2018-02-07 22:02:55 UTC (rev 228242)
+++ trunk/Source/WebCore/platform/mac/EventLoopMac.mm	2018-02-07 22:33:10 UTC (rev 228243)
@@ -36,6 +36,7 @@
         return;
     }
 #endif
+    ASSERT([NSApp isRunning]);
     [NSApp setWindowsNeedUpdate:YES];
     if (NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate dateWithTimeIntervalSinceNow:0.05] inMode:NSDefaultRunLoopMode dequeue:YES])
         [NSApp sendEvent:event];

Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (228242 => 228243)


--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm	2018-02-07 22:02:55 UTC (rev 228242)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm	2018-02-07 22:33:10 UTC (rev 228243)
@@ -658,10 +658,15 @@
 
     // Hack: We must post an event to wake up the NSDragManager, which is sitting in a nextEvent call
     // up the stack from us because the CoreFoundation drag manager does not use the run loop by itself.
-    // This is the most innocuous event to use, per Kristen Forster.
-    NSEvent* event = [NSEvent mouseEventWithType:NSEventTypeMouseMoved location:NSZeroPoint
-        modifierFlags:0 timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:0 pressure:0];
-    [NSApp postEvent:event atStart:YES];
+    // This is the most innocuous event to use, per Kristin Forster.
+    // This is only relevant in WK1. Do not execute in the WebContent process, since it is now using
+    // NSRunLoop, and not the NSApplication run loop.
+    if ([NSApp isRunning]) {
+        NSEvent* event = [NSEvent mouseEventWithType:NSEventTypeMouseMoved location:NSZeroPoint
+            modifierFlags:0 timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:0 pressure:0];
+        ASSERT([NSApp isRunning]);
+        [NSApp postEvent:event atStart:YES];
+    }
 }
 #endif
 

Modified: trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.mm (228242 => 228243)


--- trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.mm	2018-02-07 22:02:55 UTC (rev 228242)
+++ trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.mm	2018-02-07 22:33:10 UTC (rev 228243)
@@ -109,6 +109,8 @@
     [(NSView*)[window contentView] setLayer:[CALayer layer]];
     [[window contentView] setWantsLayer:YES];
 
+    ASSERT([NSApp isRunning]);
+
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidResignActive:) name:NSApplicationDidResignActiveNotification object:NSApp];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidChangeScreenParameters:) name:NSApplicationDidChangeScreenParametersNotification object:NSApp];
 }
@@ -338,6 +340,7 @@
             options |= NSApplicationPresentationAutoHideDock;
     }
 
+    ASSERT([NSApp isRunning]);
     NSApp.presentationOptions = options;
 }
 

Modified: trunk/Source/WebCore/platform/mac/WebWindowAnimation.mm (228242 => 228243)


--- trunk/Source/WebCore/platform/mac/WebWindowAnimation.mm	2018-02-07 22:02:55 UTC (rev 228242)
+++ trunk/Source/WebCore/platform/mac/WebWindowAnimation.mm	2018-02-07 22:33:10 UTC (rev 228243)
@@ -38,6 +38,7 @@
 
 static NSTimeInterval WebWindowAnimationDurationFromDuration(NSTimeInterval duration)
 {
+    ASSERT([NSApp isRunning]);
     return ([[NSApp currentEvent] modifierFlags] & NSEventModifierFlagShift) ? duration * slowMotionFactor : duration;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to