Title: [228338] trunk/Source/WebCore
Revision
228338
Author
pvol...@apple.com
Date
2018-02-09 14:13:00 -0800 (Fri, 09 Feb 2018)

Log Message

Assert that NSApp is not running in the WebProcess.
https://bugs.webkit.org/show_bug.cgi?id=182553

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 NSApp references 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228337 => 228338)


--- trunk/Source/WebCore/ChangeLog	2018-02-09 20:50:58 UTC (rev 228337)
+++ trunk/Source/WebCore/ChangeLog	2018-02-09 22:13:00 UTC (rev 228338)
@@ -1,3 +1,28 @@
+2018-02-09  Per Arne Vollan  <pvol...@apple.com>
+
+        Assert that NSApp is not running in the WebProcess.
+        https://bugs.webkit.org/show_bug.cgi?id=182553
+
+        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 NSApp references 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):
+
 2018-02-09  Zalan Bujtas  <za...@apple.com>
 
         [RenderTreeBuilder] Introduce RenderTreeBuilder to willBeDestoryed/removeFromParentAndDestroy

Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (228337 => 228338)


--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2018-02-09 20:50:58 UTC (rev 228337)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2018-02-09 22:13:00 UTC (rev 228338)
@@ -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/PasteboardMac.mm (228337 => 228338)


--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm	2018-02-09 20:50:58 UTC (rev 228337)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm	2018-02-09 22:13:00 UTC (rev 228338)
@@ -658,10 +658,14 @@
 
     // 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];
+        [NSApp postEvent:event atStart:YES];
+    }
 }
 #endif
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to