⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 175973 in webkit


Ignore:
Timestamp:
Nov 11, 2014, 1:39:46 PM (12 years ago)
Author:
timothy_horton@apple.com
Message:

Occasional assertion failure under recommendedScrollbarStyleDidChange()
https://bugs.webkit.org/show_bug.cgi?id=138604
<rdar://problem/18855914>

Reviewed by Beth Dakin.

It is possible for AppKit to install tracking areas into our view
behind our back, but we have code that depends on knowing exactly
the set of tracking areas installed on WKView.

Make this more robust by keeping a reference to the tracking area we
use for many things and manipulating that instead of making assumptions
about the total set of tracking areas on WKView.

  • UIProcess/API/mac/WKView.mm:

(-[WKView _primaryTrackingArea]):
(-[WKView _replacePrimaryTrackingArea:]):
Provide a 'primary' tracking area setter/getter.

(-[WKView initWithFrame:context:configuration:webView:]):
Keep a reference to the original tracking area installed at initialization time.

  • UIProcess/API/mac/WKViewInternal.h:
  • UIProcess/mac/PageClientImpl.mm:

(WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):
Instead of walking the set of tracking areas, make use of the fact that
we know exactly which tracking area we installed, and uninstall just that
one, and replace it with our newly-built one.

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r175972 r175973  
     12014-11-11  Tim Horton  <timothy_horton@apple.com>
     2
     3        Occasional assertion failure under recommendedScrollbarStyleDidChange()
     4        https://bugs.webkit.org/show_bug.cgi?id=138604
     5        <rdar://problem/18855914>
     6
     7        Reviewed by Beth Dakin.
     8
     9        It is possible for AppKit to install tracking areas into our view
     10        behind our back, but we have code that depends on knowing exactly
     11        the set of tracking areas installed on WKView.
     12
     13        Make this more robust by keeping a reference to the tracking area we
     14        use for many things and manipulating that instead of making assumptions
     15        about the total set of tracking areas on WKView.
     16
     17        * UIProcess/API/mac/WKView.mm:
     18        (-[WKView _primaryTrackingArea]):
     19        (-[WKView _replacePrimaryTrackingArea:]):
     20        Provide a 'primary' tracking area setter/getter.
     21
     22        (-[WKView initWithFrame:context:configuration:webView:]):
     23        Keep a reference to the original tracking area installed at initialization time.
     24
     25        * UIProcess/API/mac/WKViewInternal.h:
     26        * UIProcess/mac/PageClientImpl.mm:
     27        (WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):
     28        Instead of walking the set of tracking areas, make use of the fact that
     29        we know exactly which tracking area we installed, and uninstall just that
     30        one, and replace it with our newly-built one.
     31
    1322014-11-11  Myles C. Maxfield  <mmaxfield@apple.com>
    233
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r175790 r175973  
    170170    RetainPtr<WKBrowsingContextController> _browsingContextController;
    171171#endif
     172
     173    RetainPtr<NSTrackingArea> _primaryTrackingArea;
    172174
    173175    // For ToolTips.
     
    34943496}
    34953497
     3498- (NSTrackingArea *)_primaryTrackingArea
     3499{
     3500    return _data->_primaryTrackingArea.get();
     3501}
     3502
     3503- (void)_setPrimaryTrackingArea:(NSTrackingArea *)trackingArea
     3504{
     3505    [self removeTrackingArea:_data->_primaryTrackingArea.get()];
     3506    _data->_primaryTrackingArea = trackingArea;
     3507    [self addTrackingArea:trackingArea];
     3508}
     3509
    34963510- (instancetype)initWithFrame:(NSRect)frame context:(WebContext&)context configuration:(WebPageConfiguration)webPageConfiguration webView:(WKWebView *)webView
    34973511{
     
    35113525        options |= NSTrackingActiveInKeyWindow;
    35123526
    3513     NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:frame
    3514                                                                 options:options
    3515                                                                   owner:self
    3516                                                                userInfo:nil];
    3517     [self addTrackingArea:trackingArea];
    3518     [trackingArea release];
    3519 
    35203527    _data = [[WKViewData alloc] init];
     3528    _data->_primaryTrackingArea = adoptNS([[NSTrackingArea alloc] initWithRect:frame options:options owner:self userInfo:nil]);
     3529    [self addTrackingArea:_data->_primaryTrackingArea.get()];
     3530
    35213531    _data->_pageClient = std::make_unique<PageClientImpl>(self, webView);
    35223532    _data->_page = context.createWebPage(*_data->_pageClient, WTF::move(webPageConfiguration));
  • trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h

    r175756 r175973  
    134134- (void)_dismissActionMenuPopovers;
    135135
     136@property (nonatomic, retain, setter=_setPrimaryTrackingArea:) NSTrackingArea *_primaryTrackingArea;
     137
    136138@end
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm

    r175966 r175973  
    586586void PageClientImpl::recommendedScrollbarStyleDidChange(int32_t newStyle)
    587587{
    588     NSArray *trackingAreas = [m_wkView trackingAreas];
    589     NSUInteger count = [trackingAreas count];
    590     ASSERT(count == 1);
    591    
    592     for (NSUInteger i = 0; i < count; ++i)
    593         [m_wkView removeTrackingArea:[trackingAreas objectAtIndex:i]];
    594 
    595588    // Now re-create a tracking area with the appropriate options given the new scrollbar style
    596589    NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect;
     
    600593        options |= NSTrackingActiveInKeyWindow;
    601594
    602     NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[m_wkView frame]
    603                                                                 options:options
    604                                                                   owner:m_wkView
    605                                                                userInfo:nil];
    606     [m_wkView addTrackingArea:trackingArea];
    607     [trackingArea release];
     595    RetainPtr<NSTrackingArea> trackingArea = adoptNS([[NSTrackingArea alloc] initWithRect:[m_wkView frame] options:options owner:m_wkView userInfo:nil]);
     596    [m_wkView _setPrimaryTrackingArea:trackingArea.get()];
    608597}
    609598
Note: See TracChangeset for help on using the changeset viewer.