Title: [191506] trunk/Source/WebKit/mac
Revision
191506
Author
[email protected]
Date
2015-10-23 12:19:56 -0700 (Fri, 23 Oct 2015)

Log Message

Don't override already existing represented objects on menu items
https://bugs.webkit.org/show_bug.cgi?id=150508

Reviewed by Tim Horton.

This fixes a crash/exception when a client implements webView:contextMenuItemsForElement:defaultMenuItems: and
the default menu has a share menu item.

* WebCoreSupport/WebContextMenuClient.mm:
(WebContextMenuClient::getCustomMenuFromDefaultItems):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (191505 => 191506)


--- trunk/Source/WebKit/mac/ChangeLog	2015-10-23 19:06:23 UTC (rev 191505)
+++ trunk/Source/WebKit/mac/ChangeLog	2015-10-23 19:19:56 UTC (rev 191506)
@@ -1,3 +1,16 @@
+2015-10-23  Anders Carlsson  <[email protected]>
+
+        Don't override already existing represented objects on menu items
+        https://bugs.webkit.org/show_bug.cgi?id=150508
+
+        Reviewed by Tim Horton.
+
+        This fixes a crash/exception when a client implements webView:contextMenuItemsForElement:defaultMenuItems: and
+        the default menu has a share menu item.
+
+        * WebCoreSupport/WebContextMenuClient.mm:
+        (WebContextMenuClient::getCustomMenuFromDefaultItems):
+
 2015-10-22  Sam Weinig  <[email protected]>
 
         Navigations on the same host (but with different schemes and ports) should not trigger universal links

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm (191505 => 191506)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm	2015-10-23 19:06:23 UTC (rev 191505)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm	2015-10-23 19:19:56 UTC (rev 191506)
@@ -307,9 +307,10 @@
 
     NSMutableArray *defaultMenuItems = defaultMenu->platformDescription();
 
-    unsigned defaultItemsCount = [defaultMenuItems count];
-    for (unsigned i = 0; i < defaultItemsCount; ++i)
-        [[defaultMenuItems objectAtIndex:i] setRepresentedObject:element];
+    for (NSMenuItem *menuItem in defaultMenuItems) {
+        if (!menuItem.representedObject)
+            menuItem.representedObject = element;
+    }
 
     NSMutableArray *savedItems = [fixMenusToSendToOldClients(defaultMenuItems) retain];
     NSArray *delegateSuppliedItems = CallUIDelegate(m_webView, selector, element, defaultMenuItems);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to