Trying to lookup when WebView is in a popover causes process to hang. Fix for Legacy WebView.
Created attachment 407163 [details] Patch
<rdar://problem/52317762>
Comment on attachment 407163 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=407163&action=review > Source/WebKitLegacy/mac/WebView/WebHTMLView.mm:3682 > - auto defaultMenuItems = createMenuItems(hitTestResult, defaultMenu.items()); > + Vector<WebCore::ContextMenuItem> filteredItems; > + filteredItems.reserveInitialCapacity(defaultMenu.items().size()); > + > + bool isPopover = webView.window._childWindowOrderingPriority == NSWindowChildOrderingPriorityPopover; > + bool isLookupDisabled = [NSUserDefaults.standardUserDefaults boolForKey:@"LULookupDisabled"]; > > + for (WebCore::ContextMenuItem item : defaultMenu.items()) { > + if (item.action() != WebCore::ContextMenuItemTagLookUpInDictionary || (!isLookupDisabled && !isPopover)) > + filteredItems.uncheckedAppend(item); > + } > + > + auto defaultMenuItems = createMenuItems(hitTestResult, filteredItems); Here’s a simpler way to write it (roughly, not sure I have the syntax right: auto filteredItems = defaultMenu.items(); if (!isLookupDisabled && !isPopover) { filteredItems.removeAllMatching([] (auto& item) { return item.action() == WebCore::ContextMenuItemTagLookUpInDictionary; }); } auto defaultMenuItems = createMenuItems(hitTestResult, filteredItems);
Not a lot simpler (I accidentally left out the isPopover and isLookupDisabled part), but still I think it’s better than writing our own loop.
Created attachment 407206 [details] Patch
Committed r266143: <https://trac.webkit.org/changeset/266143> All reviewed patches have been landed. Closing bug and clearing flags on attachment 407206 [details].