Bug 214773

Summary: Trying to lookup when WebView is in a popover causes process to hang.
Product: WebKit Reporter: Megan Gardner <megan_gardner>
Component: New BugsAssignee: Megan Gardner <megan_gardner>
Status: RESOLVED FIXED    
Severity: Normal CC: drousso, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Megan Gardner 2020-07-24 17:50:53 PDT
Trying to lookup when WebView is in a popover causes process to hang.
Comment 1 Megan Gardner 2020-07-24 18:19:17 PDT
Created attachment 405210 [details]
Patch
Comment 2 Devin Rousso 2020-07-24 19:19:14 PDT
Comment on attachment 405210 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=405210&action=review

> Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:355
> +        if (!(((webView.get().window._childWindowOrderingPriority == NSWindowChildOrderingPriorityPopover) || [NSUserDefaults.standardUserDefaults boolForKey:@"LULookupDisabled"]) && items[i].action() == ContextMenuItemTagLookUpInDictionary))

Can we move the `((webView.get().window._childWindowOrderingPriority == NSWindowChildOrderingPriorityPopover) || [NSUserDefaults.standardUserDefaults boolForKey:@"LULookupDisabled"])` to a variable outside this loop so that it doesn't have to be recalculated in each iteration?
```

bool isPopover = m_webView->get().window._childWindowOrderingPriority == NSWindowChildOrderingPriorityPopover;
bool isLookupDisabled = [NSUserDefaults.standardUserDefaults boolForKey:@"LULookupDisabled"];

for (auto& item : items) {
    if (item.action() != ContextMenuItemTagLookUpInDictionary || (!isLookupDisabled && !isPopover))
        filteredItems.uncheckedAppend(item);
}
```
Comment 3 Wenson Hsieh 2020-07-24 20:04:37 PDT
Comment on attachment 405210 [details]
Patch

It looks like you’ll need to add NSWindowChildOrderingPriorityPopover to NSWindowSPI.h as well.
Comment 4 Megan Gardner 2020-07-27 08:28:05 PDT
Created attachment 405276 [details]
Patch
Comment 5 Devin Rousso 2020-07-27 09:07:26 PDT
Comment on attachment 405276 [details]
Patch

r=me
Comment 6 EWS 2020-07-27 10:04:03 PDT
Committed r264928: <https://trac.webkit.org/changeset/264928>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 405276 [details].
Comment 7 Radar WebKit Bug Importer 2020-07-27 10:05:23 PDT
<rdar://problem/66168314>