Only allow the "Copy Image" menu item for images

André Berg pointed out that the "Open Image in New Window" and "Download Image" items from the contextual menu for images in the web view does not work and may cause crashes.

So limit the menu to either just show "Copy Image" or don't have a menu at all.
This commit is contained in:
Nathan Kinsinger
2010-06-27 06:10:29 -06:00
parent 694b2ed0d7
commit 9e8002a97e
+9
View File
@@ -127,6 +127,15 @@ contextMenuItemsForElement:(NSDictionary *)element
}
if ([node hasAttributes] && [[node attributes] getNamedItem:@"representedFile"])
return [historyController menuItemsForPaths:[NSArray arrayWithObject:[[[node attributes] getNamedItem:@"representedFile"] value]]];
else if ([[node class] isEqual:[DOMHTMLImageElement class]]) {
// Copy Image is the only menu item that makes sense here since we don't need
// to download the image or open it in a new window (besides with the
// current implementation these two entries can crash GitX anyway)
for (NSMenuItem *item in defaultMenuItems)
if ([item tag] == WebMenuItemTagCopyImageToClipboard)
return [NSArray arrayWithObject:item];
return nil;
}
node = [node parentNode];
}