Changeset 228338 in webkit


Ignore:
Timestamp:
Feb 9, 2018 2:13:00 PM (6 years ago)
Author:
pvollan@apple.com
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):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r228337 r228338  
     12018-02-09  Per Arne Vollan  <pvollan@apple.com>
     2
     3        Assert that NSApp is not running in the WebProcess.
     4        https://bugs.webkit.org/show_bug.cgi?id=182553
     5
     6        Reviewed by Simon Fraser.
     7
     8        In WebCore, there are a few places where NSApp is referenced. Since the WebContent process
     9        is no longer using the NSApplication run loop, and NSApp is no longer guaranteed to be
     10        valid, we should make sure that the NSApp is not referenced by the WebContent process or
     11        the Network process, by asserting that the NSApplication event loop is running when NSApp
     12        is referenced. It is still ok for the UIProcess to reference NSApp. Adding these assert
     13        will help catch NSApp references when the NSApplication run loop is not used.
     14
     15        Also, do not post a fake mouse event in PasteBoard::setDragImage when the NSApplication
     16        run loop is not running, since this is only relevant in WK1.
     17
     18        No new tests, covered by existing tests.
     19
     20        * page/mac/EventHandlerMac.mm:
     21        (WebCore::lastEventIsMouseUp):
     22        (WebCore::EventHandler::sendFakeEventsAfterWidgetTracking):
     23        * platform/mac/PasteboardMac.mm:
     24        (WebCore::Pasteboard::setDragImage):
     25
    1262018-02-09  Zalan Bujtas  <zalan@apple.com>
    227
  • trunk/Source/WebCore/page/mac/EventHandlerMac.mm

    r228260 r228338  
    197197    // It's not clear in what cases this is helpful now -- it's possible it can be removed.
    198198
     199    ASSERT([NSApp isRunning]);
     200
    199201    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    200202    NSEvent *currentEventAfterHandlingMouseDown = [NSApp currentEvent];
     
    571573    int eventType = [initiatingEvent type];
    572574    if (eventType == NSEventTypeLeftMouseDown || eventType == NSEventTypeKeyDown) {
     575        ASSERT([NSApp isRunning]);
    573576        NSEvent *fakeEvent = nil;
    574577        if (eventType == NSEventTypeLeftMouseDown) {
  • trunk/Source/WebCore/platform/mac/PasteboardMac.mm

    r228254 r228338  
    659659    // Hack: We must post an event to wake up the NSDragManager, which is sitting in a nextEvent call
    660660    // up the stack from us because the CoreFoundation drag manager does not use the run loop by itself.
    661     // This is the most innocuous event to use, per Kristen Forster.
    662     NSEvent* event = [NSEvent mouseEventWithType:NSEventTypeMouseMoved location:NSZeroPoint
    663         modifierFlags:0 timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:0 pressure:0];
    664     [NSApp postEvent:event atStart:YES];
     661    // This is the most innocuous event to use, per Kristin Forster.
     662    // This is only relevant in WK1. Do not execute in the WebContent process, since it is now using
     663    // NSRunLoop, and not the NSApplication run loop.
     664    if ([NSApp isRunning]) {
     665        NSEvent* event = [NSEvent mouseEventWithType:NSEventTypeMouseMoved location:NSZeroPoint
     666            modifierFlags:0 timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:0 pressure:0];
     667        [NSApp postEvent:event atStart:YES];
     668    }
    665669}
    666670#endif
Note: See TracChangeset for help on using the changeset viewer.