Title: [266143] trunk/Source
Revision
266143
Author
megan_gard...@apple.com
Date
2020-08-25 14:34:18 -0700 (Tue, 25 Aug 2020)

Log Message

Trying to lookup when WebView is in a popover causes process to hang. Fix for Legacy WebView.
https://bugs.webkit.org/show_bug.cgi?id=215792

Reviewed by Tim Horton.

Source/WebKit:

Update code based on Darin's suggestion for mirror fix in legacy webkit.

* UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::getContextMenuFromItems):

Source/WebKitLegacy/mac:

Fix for https://bugs.webkit.org/show_bug.cgi?id=214773 also needed in legacy WebView.
The Lookup framework does not populate the menus that it vends with the option to 'lookup'
words that are selected in popovers. WebKit should follow the pattern and not put the
item in the menu as Lookup is not able to handle this situation. Also if Lookup is disabled
via defaults, we should not show it in the menu.

* WebView/WebHTMLView.mm:
(customMenuFromDefaultItems):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (266142 => 266143)


--- trunk/Source/WebKit/ChangeLog	2020-08-25 21:22:12 UTC (rev 266142)
+++ trunk/Source/WebKit/ChangeLog	2020-08-25 21:34:18 UTC (rev 266143)
@@ -1,3 +1,15 @@
+2020-08-25  Megan Gardner  <megan_gard...@apple.com>
+
+        Trying to lookup when WebView is in a popover causes process to hang. Fix for Legacy WebView.
+        https://bugs.webkit.org/show_bug.cgi?id=215792
+
+        Reviewed by Tim Horton.
+
+        Update code based on Darin's suggestion for mirror fix in legacy webkit.
+
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (WebKit::WebContextMenuProxyMac::getContextMenuFromItems):
+
 2020-08-25  Carlos Alberto Lopez Perez  <clo...@igalia.com>
 
         [WPE][Qt] Fix qt-wpe-minibrowser on Debian10

Modified: trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm (266142 => 266143)


--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2020-08-25 21:22:12 UTC (rev 266142)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2020-08-25 21:34:18 UTC (rev 266143)
@@ -347,16 +347,16 @@
         return;
     }
     
-    Vector<WebContextMenuItemData> filteredItems;
-    filteredItems.reserveInitialCapacity(items.size());
+    auto filteredItems = items;
     auto webView = m_webView.get();
     
     bool isPopover = webView.get().window._childWindowOrderingPriority == NSWindowChildOrderingPriorityPopover;
     bool isLookupDisabled = [NSUserDefaults.standardUserDefaults boolForKey:@"LULookupDisabled"];
-
-    for (auto& item : items) {
-        if (item.action() != ContextMenuItemTagLookUpInDictionary || (!isLookupDisabled && !isPopover))
-            filteredItems.uncheckedAppend(item);
+    
+    if (isLookupDisabled || isPopover) {
+        filteredItems.removeAllMatching([] (auto& item) {
+            return item.action() == WebCore::ContextMenuItemTagLookUpInDictionary;
+        });
     }
 
     auto sparseMenuItems = retainPtr([NSPointerArray strongObjectsPointerArray]);

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (266142 => 266143)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2020-08-25 21:22:12 UTC (rev 266142)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2020-08-25 21:34:18 UTC (rev 266143)
@@ -1,3 +1,19 @@
+2020-08-25  Megan Gardner  <megan_gard...@apple.com>
+
+        Trying to lookup when WebView is in a popover causes process to hang. Fix for Legacy WebView.
+        https://bugs.webkit.org/show_bug.cgi?id=215792
+
+        Reviewed by Tim Horton.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=214773 also needed in legacy WebView.
+        The Lookup framework does not populate the menus that it vends with the option to 'lookup'
+        words that are selected in popovers. WebKit should follow the pattern and not put the
+        item in the menu as Lookup is not able to handle this situation. Also if Lookup is disabled
+        via defaults, we should not show it in the menu.
+
+        * WebView/WebHTMLView.mm:
+        (customMenuFromDefaultItems):
+
 2020-08-24  Aditya Keerthi  <akeer...@apple.com>
 
         [macOS] Show picker for date and datetime-local input types

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (266142 => 266143)


--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2020-08-25 21:22:12 UTC (rev 266142)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2020-08-25 21:34:18 UTC (rev 266143)
@@ -3668,8 +3668,17 @@
 static RetainPtr<NSArray> customMenuFromDefaultItems(WebView *webView, const WebCore::ContextMenu& defaultMenu)
 {
     const auto& hitTestResult = webView.page->contextMenuController().hitTestResult();
-    auto defaultMenuItems = createMenuItems(hitTestResult, defaultMenu.items());
-
+    bool isPopover = webView.window._childWindowOrderingPriority == NSWindowChildOrderingPriorityPopover;
+    bool isLookupDisabled = [NSUserDefaults.standardUserDefaults boolForKey:@"LULookupDisabled"];
+    auto filteredItems = defaultMenu.items();
+    
+    if (isLookupDisabled || isPopover) {
+        filteredItems.removeAllMatching([] (auto& item) {
+            return item.action() == WebCore::ContextMenuItemTagLookUpInDictionary;
+        });
+    }
+    auto defaultMenuItems = createMenuItems(hitTestResult, filteredItems);
+    
     id delegate = [webView UIDelegate];
     SEL selector = @selector(webView:contextMenuItemsForElement:defaultMenuItems:);
     if (![delegate respondsToSelector:selector])
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to