Title: [266431] branches/safari-610-branch/Source
Revision
266431
Author
[email protected]
Date
2020-09-01 18:19:14 -0700 (Tue, 01 Sep 2020)

Log Message

Cherry-pick r266143. rdar://problem/68164547

    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):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266143 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610-branch/Source/WebKit/ChangeLog (266430 => 266431)


--- branches/safari-610-branch/Source/WebKit/ChangeLog	2020-09-02 01:19:11 UTC (rev 266430)
+++ branches/safari-610-branch/Source/WebKit/ChangeLog	2020-09-02 01:19:14 UTC (rev 266431)
@@ -1,5 +1,47 @@
 2020-09-01  Alan Coon  <[email protected]>
 
+        Cherry-pick r266143. rdar://problem/68164547
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266143 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-25  Megan Gardner  <[email protected]>
+
+            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-09-01  Alan Coon  <[email protected]>
+
         Cherry-pick r266134. rdar://problem/68164543
 
     [Mac] REGRESSION(r262322): Focusable elements are focused when exiting from video fullscreen mode.

Modified: branches/safari-610-branch/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm (266430 => 266431)


--- branches/safari-610-branch/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2020-09-02 01:19:11 UTC (rev 266430)
+++ branches/safari-610-branch/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2020-09-02 01:19:14 UTC (rev 266431)
@@ -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: branches/safari-610-branch/Source/WebKitLegacy/mac/ChangeLog (266430 => 266431)


--- branches/safari-610-branch/Source/WebKitLegacy/mac/ChangeLog	2020-09-02 01:19:11 UTC (rev 266430)
+++ branches/safari-610-branch/Source/WebKitLegacy/mac/ChangeLog	2020-09-02 01:19:14 UTC (rev 266431)
@@ -1,3 +1,49 @@
+2020-09-01  Alan Coon  <[email protected]>
+
+        Cherry-pick r266143. rdar://problem/68164547
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266143 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-25  Megan Gardner  <[email protected]>
+
+            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-17  David Kilzer  <[email protected]>
 
         Clean up DragApplicationFlags after switch to OptionSet<>

Modified: branches/safari-610-branch/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (266430 => 266431)


--- branches/safari-610-branch/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2020-09-02 01:19:11 UTC (rev 266430)
+++ branches/safari-610-branch/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2020-09-02 01:19:14 UTC (rev 266431)
@@ -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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to