[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:23:43 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit d53e8883c80d771c7ee7baa15f68bf0ecd6e58e3
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Feb 6 06:34:49 2003 +0000

    WebKit:
    
    	WebKit API clean-up:
    	- Added enum to WebContextMenuDelegate that is the menu item tag of the menu items passed in the default menu item array.
    	- WebPluginError should return URL strings.
    	- Made WebContextMenuDelegate constructors private.
    
            Reviewed by rjw.
    
            * Plugins.subproj/WebNetscapePluginDocumentView.m:
            (-[WebNetscapePluginDocumentView setDataSource:]):
            * Plugins.subproj/WebPluginError.h:
            * Plugins.subproj/WebPluginError.m:
            (-[WebPluginError pluginPageURL]):
            * Plugins.subproj/WebPluginErrorPrivate.h: Added.
            * WebCoreSupport.subproj/WebBridge.m:
            (-[WebBridge viewForPluginWithURL:attributes:baseURL:MIMEType:]):
            * WebKit.pbproj/project.pbxproj:
            * WebView.subproj/WebContextMenuDelegate.h:
            * WebView.subproj/WebDefaultContextMenuDelegate.h:
            * WebView.subproj/WebDefaultContextMenuDelegate.m:
            (-[WebDefaultContextMenuDelegate menuItemWithTag:]):
            (-[WebDefaultContextMenuDelegate contextMenuItemsForElement:defaultMenuItems:]):
    
    WebBrowser:
    
    	WebKit API clean-up:
    	- Added enum to WebContextMenuDelegate that is the menu item tag of the menu items passed in the default menu item array.
    	- WebPluginError should return URL strings.
    	- Made WebContextMenuDelegate constructors private.
    
    
            Reviewed by rjw.
    
            * ContextMenuHandler.m:
            (-[ContextMenuHandler addMenuItemWithTag:fromArray:toArray:]):
            (-[ContextMenuHandler addMenuItemWithTitle:action:toArray:]):
            (-[ContextMenuHandler contextMenuItemsForElement:defaultMenuItems:]):
            * LoadProgressMonitor.m:
            (-[LoadProgressMonitor launchApplicationSheetEnded:returnCode:contextInfo:]):
            (-[LoadProgressMonitor pluginErrorSheetEnded:returnCode:contextInfo:]):
            (-[LoadProgressMonitor pluginFailedWithError:dataSource:]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3580 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index c5990df..12130a7 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,27 @@
+2003-02-05  Chris Blumenberg  <cblu at apple.com>
+
+	WebKit API clean-up:
+	- Added enum to WebContextMenuDelegate that is the menu item tag of the menu items passed in the default menu item array.
+	- WebPluginError should return URL strings.
+	- Made WebContextMenuDelegate constructors private.
+
+        Reviewed by rjw.
+
+        * Plugins.subproj/WebNetscapePluginDocumentView.m:
+        (-[WebNetscapePluginDocumentView setDataSource:]):
+        * Plugins.subproj/WebPluginError.h:
+        * Plugins.subproj/WebPluginError.m:
+        (-[WebPluginError pluginPageURL]):
+        * Plugins.subproj/WebPluginErrorPrivate.h: Added.
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge viewForPluginWithURL:attributes:baseURL:MIMEType:]):
+        * WebKit.pbproj/project.pbxproj:
+        * WebView.subproj/WebContextMenuDelegate.h:
+        * WebView.subproj/WebDefaultContextMenuDelegate.h:
+        * WebView.subproj/WebDefaultContextMenuDelegate.m:
+        (-[WebDefaultContextMenuDelegate menuItemWithTag:]):
+        (-[WebDefaultContextMenuDelegate contextMenuItemsForElement:defaultMenuItems:]):
+
 2003-02-04  Trey Matteson  <trey at apple.com>
 
 	WC now tells us the form values being submitted with a get/post.
@@ -312,7 +336,8 @@
 
 	Fixed: 3160464 - Slideback sometimes happens twice
 
-	Because we start drags in mouseDragged (which AppKit says we shouldn't), we get mouseDragged events after a drag (image, link, text etc) has ended. We also get mouseDragged events after we've sent the fake mouseUp to WebCore. That is probably bad for unknown reasons.
+	Because we start drags in mouseDragged (which AppKit says we shouldn't), we get mouseDragged events after a drag (image, link, text etc) has ended. We also get mouseDragged events after we've sent the fake mouseUp to WebCore. That is probably bad for unk
+nown reasons.
 
         Reviewed by darin.
 
@@ -804,7 +829,8 @@
 
 2003-01-22  Chris Blumenberg  <cblu at apple.com>
 
-	Fixed problem where we weren't stopping the Java plug-in. This problem was introduced on Jan. 1 when the ownership of the WebPluginController was moved from WebFrame to WebDataSource. This change moves the WebPluginController to the WebHTMLView. Why this change?
+	Fixed problem where we weren't stopping the Java plug-in. This problem was introduced on Jan. 1 when the ownership of the WebPluginController was moved from WebFrame to WebDataSource. This change moves the WebPluginController to the WebHTMLView. Why this
+ change?
 
 	- The state of the plug-ins (currently only the Java plug-in) completely relies on the state of the WebHTMLView, not on the state of the WebDataSource.
 
@@ -2118,7 +2144,8 @@
 
 	Fixed: 3131714 - System becomes unresponsive while downloading
 
-	While downloading a file, Safari and the Finder take up 30%-40% of the CPU each. This is happening because for every chunk of data we write to disk, we call -[NSWorkspace noteFileSystemChanged:]. noteFileSystemChanged is inefficient. It calls 2 AppleEvents each with 60 timeouts. The event also cause the Finder to do a lot of work.
+	While downloading a file, Safari and the Finder take up 30%-40% of the CPU each. This is happening because for every chunk of data we write to disk, we call -[NSWorkspace noteFileSystemChanged:]. noteFileSystemChanged is inefficient. It calls 2 AppleEven
+ts each with 60 timeouts. The event also cause the Finder to do a lot of work.
 
 	We should:
 	- Send 1 AppleEvent ourselves with no timeout since we don't care about the reply
@@ -2133,7 +2160,8 @@
         (-[WebDownloadHandler finishedLoading]): call _web_noteFileChangedAtPath
         * Misc.subproj/WebNSWorkspaceExtras.h: Added.
         * Misc.subproj/WebNSWorkspaceExtras.m: Added.
-        (-[NSWorkspace _web_noteFileChangedAtPath:]): Notifies the Finder (or any other app that cares) that we added, removed or changed the attributes of a file. This method is better than calling noteFileSystemChanged: because noteFileSystemChanged: sends 2 apple events both with a 60 second timeout. This method returns immediately.
+        (-[NSWorkspace _web_noteFileChangedAtPath:]): Notifies the Finder (or any other app that cares) that we added, removed or changed the attributes of a file. This method is better than calling noteFileSystemChanged: because noteFileSystemChanged: se
+nds 2 apple events both with a 60 second timeout. This method returns immediately.
         * WebKit.pbproj/project.pbxproj:
 
 2002-12-18  Darin Adler  <darin at apple.com>
@@ -2759,7 +2787,8 @@
 
         Reviewed by john.
 
-	We were reusing the drag types from the previous drag pasteboard. For example, we would declare image types when dragging URLs. This would confuse the Finder, so location files weren't being created. This would occasional cause us to crash because we weren't providing the declared data. 
+	We were reusing the drag types from the previous drag pasteboard. For example, we would declare image types when dragging URLs. This would confuse the Finder, so location files weren't being created. This would occasional cause us to crash because we wer
+en't providing the declared data. 
 
         * Misc.subproj/WebNSPasteboardExtras.h:
         * Misc.subproj/WebNSPasteboardExtras.m:
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m b/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m
index 77c8209..a8bc7e7 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m
@@ -12,7 +12,7 @@
 #import <WebKit/WebNSViewExtras.h>
 #import <WebKit/WebNetscapePluginPackage.h>
 #import <WebKit/WebPluginDatabase.h>
-#import <WebKit/WebPluginError.h>
+#import <WebKit/WebPluginErrorPrivate.h>
 #import <WebKit/WebResourceLoadDelegate.h>
 #import <WebKit/WebView.h>
 
@@ -73,7 +73,7 @@
         // FIXME: It would be nice to stop the load here.
         
         WebPluginError *error = [WebPluginError pluginErrorWithCode:WebErrorCannotLoadPlugin
-                                                         contentURL:[theDataSource URL]
+                                                         contentURL:[[theDataSource URL] absoluteString]
                                                       pluginPageURL:nil
                                                          pluginName:[thePlugin name]
                                                            MIMEType:MIME];
diff --git a/WebKit/Plugins.subproj/WebPlugInError.h b/WebKit/Plugins.subproj/WebPlugInError.h
index 0f5ba25..634c6d4 100644
--- a/WebKit/Plugins.subproj/WebPlugInError.h
+++ b/WebKit/Plugins.subproj/WebPlugInError.h
@@ -18,20 +18,8 @@
     WebPluginErrorPrivate *_private;
 }
 
-+ (WebPluginError *)pluginErrorWithCode:(int)code
-                             contentURL:(NSURL *)contentURL
-                          pluginPageURL:(NSURL *)URL
-                             pluginName:(NSString *)pluginName
-                               MIMEType:(NSString *)MIMEType;
-
-- initWithErrorWithCode:(int)code
-             contentURL:(NSURL *)contentURL
-          pluginPageURL:(NSURL *)pluginPageURL
-             pluginName:(NSString *)pluginName
-               MIMEType:(NSString *)MIMEType;
-
-- (NSURL *)contentURL;
-- (NSURL *)pluginPageURL;
+- (NSString *)contentURL;
+- (NSString *)pluginPageURL;
 - (NSString *)pluginName;
 - (NSString *)MIMEType;
 
diff --git a/WebKit/Plugins.subproj/WebPlugInError.m b/WebKit/Plugins.subproj/WebPlugInError.m
index 16d764f..f2f5b6d 100644
--- a/WebKit/Plugins.subproj/WebPlugInError.m
+++ b/WebKit/Plugins.subproj/WebPlugInError.m
@@ -7,14 +7,14 @@
 //
 
 #import <WebKit/WebKitErrors.h>
-#import <WebKit/WebPluginError.h>
+#import <WebKit/WebPluginErrorPrivate.h>
 
 
 @interface WebPluginErrorPrivate : NSObject
 {
 @public
-    NSURL *contentURL;
-    NSURL *pluginPageURL;
+    NSString *contentURL;
+    NSString *pluginPageURL;
     NSString *MIMEType;
     NSString *pluginName;
 }
@@ -36,49 +36,18 @@
 
 @implementation WebPluginError
 
-+ (WebPluginError *)pluginErrorWithCode:(int)code
-                             contentURL:(NSURL *)contentURL
-                          pluginPageURL:(NSURL *)pluginPageURL
-                             pluginName:(NSString *)pluginName
-                               MIMEType:(NSString *)MIMEType;
-{
-    WebPluginError *error = [[WebPluginError alloc] initWithErrorWithCode:code
-                                                               contentURL:contentURL
-                                                            pluginPageURL:pluginPageURL
-                                                               pluginName:pluginName
-                                                                 MIMEType:MIMEType];
-    return [error autorelease];
-}
-
-- initWithErrorWithCode:(int)code
-             contentURL:(NSURL *)contentURL
-          pluginPageURL:(NSURL *)pluginPageURL
-             pluginName:(NSString *)pluginName
-               MIMEType:(NSString *)MIMEType;
-{
-    [super initWithErrorCode:code inDomain:WebErrorDomainWebKit failingURL:[contentURL absoluteString]];
-    
-    _private = [[WebPluginErrorPrivate alloc] init];
-    _private->contentURL = [contentURL retain];
-    _private->pluginPageURL = [pluginPageURL retain];
-    _private->pluginName = [pluginName retain];
-    _private->MIMEType = [MIMEType retain];
-    
-    return self;
-}
-
 - (void)dealloc
 {
     [_private release];
     [super dealloc];
 }
 
-- (NSURL *)contentURL;
+- (NSString *)contentURL;
 {
     return _private->contentURL;
 }
 
-- (NSURL *)pluginPageURL
+- (NSString *)pluginPageURL
 {
     return _private->pluginPageURL;
 }
@@ -95,3 +64,39 @@
 
 @end
 
+ at implementation WebPluginError (WebPrivate)
+
++ (WebPluginError *)pluginErrorWithCode:(int)code
+                             contentURL:(NSString *)contentURL
+                          pluginPageURL:(NSString *)pluginPageURL
+                             pluginName:(NSString *)pluginName
+                               MIMEType:(NSString *)MIMEType;
+{
+    WebPluginError *error = [[WebPluginError alloc] initWithErrorWithCode:code
+                                                               contentURL:contentURL
+                                                            pluginPageURL:pluginPageURL
+                                                               pluginName:pluginName
+                                                                 MIMEType:MIMEType];
+    return [error autorelease];
+}
+
+- initWithErrorWithCode:(int)code
+             contentURL:(NSString *)contentURL
+          pluginPageURL:(NSString *)pluginPageURL
+             pluginName:(NSString *)pluginName
+               MIMEType:(NSString *)MIMEType;
+{
+    [super initWithErrorCode:code inDomain:WebErrorDomainWebKit failingURL:contentURL];
+
+    _private = [[WebPluginErrorPrivate alloc] init];
+    _private->contentURL = [contentURL retain];
+    _private->pluginPageURL = [pluginPageURL retain];
+    _private->pluginName = [pluginName retain];
+    _private->MIMEType = [MIMEType retain];
+
+    return self;
+}
+
+ at end
+
+
diff --git a/WebKit/Plugins.subproj/WebPluginErrorPrivate.h b/WebKit/Plugins.subproj/WebPluginErrorPrivate.h
new file mode 100644
index 0000000..51c5944
--- /dev/null
+++ b/WebKit/Plugins.subproj/WebPluginErrorPrivate.h
@@ -0,0 +1,26 @@
+/*
+ *  WebPluginErrorPrivate.h
+ *  WebKit
+ *
+ *  Created by Chris Blumenberg on Wed Feb 05 2003.
+ *  Copyright (c) 2003 Apple Computer. All rights reserved.
+ *
+ */
+
+#import <WebKit/WebPluginError.h>
+
+ at interface WebPluginError (WebPrivate)
+
++ (WebPluginError *)pluginErrorWithCode:(int)code
+                             contentURL:(NSString *)contentURL
+                          pluginPageURL:(NSString *)URL
+                             pluginName:(NSString *)pluginName
+                               MIMEType:(NSString *)MIMEType;
+
+- initWithErrorWithCode:(int)code
+             contentURL:(NSString *)contentURL
+          pluginPageURL:(NSString *)pluginPageURL
+             pluginName:(NSString *)pluginName
+               MIMEType:(NSString *)MIMEType;
+
+ at end
\ No newline at end of file
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 4440514..56c8d5a 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -24,7 +24,7 @@
 #import <WebKit/WebPlugin.h>
 #import <WebKit/WebPluginController.h>
 #import <WebKit/WebPluginDatabase.h>
-#import <WebKit/WebPluginError.h>
+#import <WebKit/WebPluginErrorPrivate.h>
 #import <WebKit/WebPluginPackage.h>
 #import <WebKit/WebPluginViewFactory.h>
 #import <WebKit/WebNetscapePluginDocumentView.h>
@@ -475,15 +475,9 @@
     }
 
     if(errorCode){
-        NSString *pluginPageString = [attributes objectForKey:@"pluginspage"];
-        NSURL *pluginPageURL = nil;
-        if(pluginPageString){
-            pluginPageURL = [NSURL _web_URLWithString:pluginPageString];
-        }
-
         WebPluginError *error = [WebPluginError pluginErrorWithCode:errorCode
-                                                         contentURL:[NSURL _web_URLWithString:URL]
-                                                      pluginPageURL:pluginPageURL
+                                                         contentURL:URL
+                                                      pluginPageURL:[attributes objectForKey:@"pluginspage"]
                                                          pluginName:[pluginPackage name]
                                                            MIMEType:MIMEType];
         
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 35a0209..732da2a 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -298,6 +298,7 @@
 				516F297003A6C45A00CA2D3A,
 				832B2D1603B10990009CF105,
 				84A992C403CE696800CA2ACA,
+				8466AEDE03F1F82100CA2ACA,
 			);
 			isa = PBXHeadersBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1241,7 +1242,6 @@
 			isa = PBXBuildFile;
 			settings = {
 				ATTRIBUTES = (
-					Private,
 				);
 			};
 		};
@@ -1863,6 +1863,18 @@
 //842
 //843
 //844
+		8466AEDD03F1F82100CA2ACA = {
+			fileEncoding = 4;
+			isa = PBXFileReference;
+			path = WebPluginErrorPrivate.h;
+			refType = 4;
+		};
+		8466AEDE03F1F82100CA2ACA = {
+			fileRef = 8466AEDD03F1F82100CA2ACA;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		8467275C0367158500CA2ACA = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
@@ -3567,6 +3579,7 @@
 				F5F717200288493C018635CA,
 				F5F717210288493C018635CA,
 				830A567203731461000C720C,
+				8466AEDD03F1F82100CA2ACA,
 				830A567303731461000C720C,
 			);
 			isa = PBXGroup;
diff --git a/WebKit/WebView.subproj/WebContextMenuDelegate.h b/WebKit/WebView.subproj/WebContextMenuDelegate.h
index 1c06781..c7d0c18 100644
--- a/WebKit/WebView.subproj/WebContextMenuDelegate.h
+++ b/WebKit/WebView.subproj/WebContextMenuDelegate.h
@@ -11,6 +11,24 @@
     a clicked element.
 */
 
+/*!
+    @enum WebMenuItemTag
+    @discussion Each menu item in the default menu items array passed in
+    contextMenuItemsForElement:defaultMenuItems: has its tag set to one of the WebMenuItemTags.
+    When iterating through the default menu items array, use the tag to differentiate between them.
+*/
+
+enum {
+    WebMenuItemTagOpenLinkInNewWindow=1,
+    WebMenuItemTagDownloadLinkToDisk,
+    WebMenuItemTagCopyLinkToClipboard,
+    WebMenuItemTagOpenImageInNewWindow,
+    WebMenuItemTagDownloadImageToDisk,
+    WebMenuItemTagCopyImageToClipboard,
+    WebMenuItemTagOpenFrameInNewWindow,
+    WebMenuItemTagCopy
+};
+
 @protocol WebContextMenuDelegate <NSObject>
 
 /*!
@@ -18,7 +36,7 @@
     @discussion Returns the array of NSMenuItems that will be displayed in the context menu 
     for the dictionary representation of the clicked element.
 */
-- (NSArray *)contextMenuItemsForElement: (NSDictionary *)element  defaultMenuItems: (NSArray *)menuItems;
+- (NSArray *)contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems;
 
 @end
 
diff --git a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.h b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.h
index a0272d7..f7d1548 100644
--- a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.h
+++ b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.h
@@ -10,24 +10,10 @@
 
 @protocol WebContextMenuDelegate;
 
-/*!
-    @class WebDefaultContextMenuHandler
-*/
+
 @interface WebDefaultContextMenuDelegate : NSObject <WebContextMenuDelegate>
 {
     NSDictionary *element;
 }
 
-/*!
-    @method addMenuItemWithTitle:action:target:toArray:
-    @abstract Convenience method that creates and adds a menu item an array. Usually used by the
-    WebContextMenuDelegate when constructing the array of menu items returned in
-    contextMenuItemsForElement:defaultMenuItems:
-    @param title Title of the menu item.
-    @param selector The menu item's selector.
-    @param target The target of the selector.
-    @param menuItems The array of menu items that should eventually be returned in contextMenuItemsForElement:defaultMenuItems:
-*/
-+ (void)addMenuItemWithTitle:(NSString *)title action:(SEL)selector target:(id)target toArray:(NSMutableArray *)menuItems;
-
 @end
diff --git a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
index 29b7b27..17eb3b1 100644
--- a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
+++ b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
@@ -28,12 +28,58 @@
     [super dealloc];
 }
 
-+ (void)addMenuItemWithTitle:(NSString *)title action:(SEL)selector target:(id)target toArray:(NSMutableArray *)menuItems
+- (NSMenuItem *)menuItemWithTag:(int)tag
 {
-    NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:title action:selector keyEquivalent:@""];
-    [menuItem setTarget:target];
-    [menuItems addObject:menuItem];
-    [menuItem release];
+    NSMenuItem *menuItem = [[NSMenuItem alloc] init];
+    [menuItem setTarget:self];
+    [menuItem setTag:tag];
+    
+    NSString *title;
+    SEL action;
+    
+    switch(tag) {
+        case WebMenuItemTagOpenLinkInNewWindow:
+            title = UI_STRING("Open Link in New Window", "Open in New Window context menu item");
+            action = @selector(openLinkInNewWindow:);
+            break;
+        case WebMenuItemTagDownloadLinkToDisk:
+            title = UI_STRING("Download Link to Disk", "Download Link to Disk context menu item");
+            action = @selector(downloadLinkToDisk:);
+            break;
+        case WebMenuItemTagCopyLinkToClipboard:
+            title = UI_STRING("Copy Link to Clipboard", "Copy Link to Clipboard context menu item");
+            action = @selector(copyLinkToClipboard:);
+            break;
+        case WebMenuItemTagOpenImageInNewWindow:
+            title = UI_STRING("Open Image in New Window", "Open Image in New Window context menu item");
+            action = @selector(openImageInNewWindow:);
+            break;
+        case WebMenuItemTagDownloadImageToDisk:
+            title = UI_STRING("Download Image To Disk", "Download Image To Disk context menu item");
+            action = @selector(downloadImageToDisk:);
+            break;
+        case WebMenuItemTagCopyImageToClipboard:
+            title = UI_STRING("Copy Image to Clipboard", "Copy Image to Clipboard context menu item");
+            action = @selector(copyImageToClipboard:);
+            break;
+        case WebMenuItemTagOpenFrameInNewWindow:
+            title = UI_STRING("Open Frame in New Window", "Open Frame in New Window context menu item");
+            action = @selector(openFrameInNewWindow:);
+            break;
+        case WebMenuItemTagCopy:
+            title = UI_STRING("Copy", "Copy context menu item");
+            action = @selector(copy:);
+            [menuItem setTarget:nil];
+            break;
+        default:
+            [menuItem release];
+            return nil;
+    }
+
+    [menuItem setTitle:title];
+    [menuItem setAction:action];
+    
+    return [menuItem autorelease];
 }
 
 - (NSArray *)contextMenuItemsForElement: (NSDictionary *)theElement  defaultMenuItems: (NSArray *)defaultMenuItems
@@ -46,64 +92,32 @@
 
     linkURL = [element objectForKey:WebElementLinkURLKey];
 
-    if(linkURL){
+    if (linkURL) {
         if([WebResourceHandle canInitWithRequest:[WebResourceRequest requestWithURL:linkURL]]){
-            [[self class] addMenuItemWithTitle:UI_STRING("Open Link in New Window", "Open in New Window context menu item")
-                                        action:@selector(openLinkInNewWindow:)
-                                        target:self
-                                       toArray:menuItems];
-
-            [[self class] addMenuItemWithTitle:UI_STRING("Download Link to Disk", "Download Link to Disk context menu item")
-                                        action:@selector(downloadLinkToDisk:)
-                                        target:self
-                                       toArray:menuItems];
+            [menuItems addObject:[self menuItemWithTag:WebMenuItemTagOpenLinkInNewWindow]];
+            [menuItems addObject:[self menuItemWithTag:WebMenuItemTagDownloadLinkToDisk]];
+            [menuItems addObject:[self menuItemWithTag:WebMenuItemTagCopyLinkToClipboard]];
         }
-
-        [[self class] addMenuItemWithTitle:UI_STRING("Copy Link to Clipboard", "Copy Link to Clipboard context menu item")
-                                    action:@selector(copyLinkToClipboard:)
-                                    target:self
-                                   toArray:menuItems];
     }
 
     imageURL = [element objectForKey:WebElementImageURLKey];
-
     if(imageURL){
-        
         if(linkURL){
             [menuItems addObject:[NSMenuItem separatorItem]];
         }
-
-        [[self class] addMenuItemWithTitle:UI_STRING("Open Image in New Window", "Open Image in New Window context menu item")
-                                    action:@selector(openImageInNewWindow:)
-                                    target:self
-                                   toArray:menuItems];
-
-        [[self class] addMenuItemWithTitle:UI_STRING("Download Image To Disk", "Download Image To Disk context menu item")
-                                    action:@selector(downloadImageToDisk:)
-                                    target:self
-                                   toArray:menuItems];
-
-        [[self class] addMenuItemWithTitle:UI_STRING("Copy Image to Clipboard", "Copy Image to Clipboard context menu item")
-                                    action:@selector(copyImageToClipboard:)
-                                    target:self
-                                   toArray:menuItems];
+        [menuItems addObject:[self menuItemWithTag:WebMenuItemTagOpenImageInNewWindow]];
+        [menuItems addObject:[self menuItemWithTag:WebMenuItemTagDownloadImageToDisk]];
+        [menuItems addObject:[self menuItemWithTag:WebMenuItemTagCopyImageToClipboard]];
     }
 
     if (!imageURL && !linkURL) {
-
         if ([[element objectForKey:WebElementIsSelectedTextKey] boolValue]) {
-            [[self class] addMenuItemWithTitle:UI_STRING("Copy", "Copy context menu item")
-                                        action:@selector(copy:)
-                                        target:nil
-                                       toArray:menuItems];
+            [menuItems addObject:[self menuItemWithTag:WebMenuItemTagCopy]];
         } else {        
             WebFrame *webFrame = [element objectForKey:WebElementFrameKey];
     
             if(webFrame != [[webFrame controller] mainFrame]){
-                [[self class] addMenuItemWithTitle:UI_STRING("Open Frame in New Window", "Open Frame in New Window context menu item")
-                                            action:@selector(openFrameInNewWindow:)
-                                            target:self
-                                        toArray:menuItems];
+                [menuItems addObject:[self menuItemWithTag:WebMenuItemTagOpenFrameInNewWindow]];
             }
         }
     }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list