Title: [191517] trunk/Source/WebKit/mac
Revision
191517
Author
[email protected]
Date
2015-10-23 16:47:45 -0700 (Fri, 23 Oct 2015)

Log Message

More context menu simplification
https://bugs.webkit.org/show_bug.cgi?id=150519

Reviewed by Tim Horton.

There's no need to convert the menu items back to ContextMenuItems just so we can check whether its
represented object is the sharing service picker. Also, move the check to the second loop.

* WebView/WebHTMLView.mm:
(-[WebHTMLView menuForEvent:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (191516 => 191517)


--- trunk/Source/WebKit/mac/ChangeLog	2015-10-23 23:07:18 UTC (rev 191516)
+++ trunk/Source/WebKit/mac/ChangeLog	2015-10-23 23:47:45 UTC (rev 191517)
@@ -1,5 +1,18 @@
 2015-10-23  Anders Carlsson  <[email protected]>
 
+        More context menu simplification
+        https://bugs.webkit.org/show_bug.cgi?id=150519
+
+        Reviewed by Tim Horton.
+
+        There's no need to convert the menu items back to ContextMenuItems just so we can check whether its
+        represented object is the sharing service picker. Also, move the check to the second loop.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView menuForEvent:]):
+
+2015-10-23  Anders Carlsson  <[email protected]>
+
         Simplify the WebKitLegacy menu conversion code
         https://bugs.webkit.org/show_bug.cgi?id=150509
 

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (191516 => 191517)


--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2015-10-23 23:07:18 UTC (rev 191516)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2015-10-23 23:47:45 UTC (rev 191517)
@@ -3365,21 +3365,6 @@
     if (!coreMenu)
         return nil;
 
-    auto menuItemVector = contextMenuItemVector(coreMenu->platformDescription());
-    for (auto& menuItem : menuItemVector) {
-        if (menuItem.action() != ContextMenuItemTagShareMenu)
-            continue;
-
-        NSMenuItem *nsItem = menuItem.platformDescription();
-        if (![nsItem.representedObject isKindOfClass:[NSSharingServicePicker class]]) {
-            ASSERT_NOT_REACHED();
-            continue;
-        }
-#if ENABLE(SERVICE_CONTROLS)
-        _private->currentSharingServicePickerController = adoptNS([[WebSharingServicePickerController alloc] initWithSharingServicePicker:nsItem.representedObject client:static_cast<WebContextMenuClient&>(page->contextMenuController().client())]);
-#endif
-    }
-
     NSArray* menuItems = coreMenu->platformDescription();
     if (!menuItems)
         return nil;
@@ -3388,14 +3373,24 @@
     if (!count)
         return nil;
 
-    NSMenu* menu = [[[NSMenu alloc] init] autorelease];
-    for (NSUInteger i = 0; i < count; i++)
-        [menu addItem:[menuItems objectAtIndex:i]];
-    setMenuTargets(menu);
+    auto menu = adoptNS([[NSMenu alloc] init]);
+
+    for (NSMenuItem *item in menuItems) {
+        [menu addItem:item];
+
+        if (item.tag == ContextMenuItemTagShareMenu) {
+            ASSERT([item.representedObject isKindOfClass:[NSSharingServicePicker class]]);
+#if ENABLE(SERVICE_CONTROLS)
+            _private->currentSharingServicePickerController = adoptNS([[WebSharingServicePickerController alloc] initWithSharingServicePicker:item.representedObject client:static_cast<WebContextMenuClient&>(page->contextMenuController().client())]);
+#endif
+        }
+
+    }
+    setMenuTargets(menu.get());
     
     [[WebMenuTarget sharedMenuTarget] setMenuController:&page->contextMenuController()];
     
-    return menu;
+    return menu.autorelease();
 }
 #endif // !PLATFORM(IOS)
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to