[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 06:27:07 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 9a75af344e2583c55f9c340b3d7d35aa9ecad091
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jul 24 22:36:02 2002 +0000

    	Implemented initial contextual menus. All disabled right now.
    
            * WebView.subproj/WebDefaultContextMenuHandler.h:
            * WebView.subproj/WebDefaultContextMenuHandler.m:
            (-[WebDefaultContextMenuHandler dealloc]): added
            (-[WebDefaultContextMenuHandler addMenuItemWithTitle:action:toArray:]): added
            (-[WebDefaultContextMenuHandler contextMenuItemsForElementInfo:defaultMenuItems:]): create menu items
            * WebView.subproj/WebHTMLView.m:
            (-[WebHTMLView menuForEvent:]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1660 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 325e772..ca54b9d 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,17 @@
 2002-07-24  Chris Blumenberg  <cblu at apple.com>
 
+	Implemented initial contextual menus. None activated yet.
+
+        * WebView.subproj/WebDefaultContextMenuHandler.h:
+        * WebView.subproj/WebDefaultContextMenuHandler.m:
+        (-[WebDefaultContextMenuHandler dealloc]): added
+        (-[WebDefaultContextMenuHandler addMenuItemWithTitle:action:toArray:]): added
+        (-[WebDefaultContextMenuHandler contextMenuItemsForElementInfo:defaultMenuItems:]): create menu items
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView menuForEvent:]): 
+
+2002-07-24  Chris Blumenberg  <cblu at apple.com>
+
 	More renaming for WebDefaultPolicyHandler.
 
         * WebView.subproj/WebController.m:
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 325e772..ca54b9d 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,5 +1,17 @@
 2002-07-24  Chris Blumenberg  <cblu at apple.com>
 
+	Implemented initial contextual menus. None activated yet.
+
+        * WebView.subproj/WebDefaultContextMenuHandler.h:
+        * WebView.subproj/WebDefaultContextMenuHandler.m:
+        (-[WebDefaultContextMenuHandler dealloc]): added
+        (-[WebDefaultContextMenuHandler addMenuItemWithTitle:action:toArray:]): added
+        (-[WebDefaultContextMenuHandler contextMenuItemsForElementInfo:defaultMenuItems:]): create menu items
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView menuForEvent:]): 
+
+2002-07-24  Chris Blumenberg  <cblu at apple.com>
+
 	More renaming for WebDefaultPolicyHandler.
 
         * WebView.subproj/WebController.m:
diff --git a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.h b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.h
index 1cf7f31..c0b1814 100644
--- a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.h
+++ b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.h
@@ -12,7 +12,7 @@
 @protocol WebContextMenuHandler;
 
 @interface WebDefaultContextMenuHandler : NSObject <WebContextMenuHandler> {
-
+    NSDictionary *currentInfo;
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
index f43589f..4c4cda3 100644
--- a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
+++ b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
@@ -5,14 +5,92 @@
 
 */
 
-#import "WebDefaultContextMenuHandler.h"
-
+#import <WebKit/WebController.h>
+#import <WebKit/WebDataSource.h>
+#import <WebKit/WebDefaultContextMenuHandler.h>
+#import <WebKit/WebFrame.h>
 
 @implementation WebDefaultContextMenuHandler
 
-- (NSArray *)contextMenuItemsForElementInfo: (NSDictionary *)elementInfo  defaultMenuItems: (NSArray *)menuItems
+- (void)dealloc
+{
+    [currentInfo release];
+    [super dealloc];
+}
+
+- (void)addMenuItemWithTitle:(NSString *)title action:(SEL)selector toArray:(NSMutableArray *)menuItems
 {
-    return nil;
+    NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:title action:selector keyEquivalent:@""];
+    [menuItem setTarget:self];
+    [menuItems addObject:menuItem];
+    [menuItem release];
+}
+
+- (NSArray *)contextMenuItemsForElementInfo: (NSDictionary *)elementInfo  defaultMenuItems: (NSArray *)defaultMenuItems
+{
+    NSMutableArray *menuItems = [NSMutableArray array];
+    NSURL *linkURL, *imageURL;
+    
+    currentInfo = [elementInfo retain];
+
+    linkURL = [currentInfo objectForKey:WebContextLinkURL];
+
+    if(linkURL){
+        [self addMenuItemWithTitle:NSLocalizedString(@"Open Link in New Window", @"Open in New Window context menu item") 				            action:@selector(openInNewWindow:)
+                           toArray:menuItems];
+        
+        [self addMenuItemWithTitle:NSLocalizedString(@"Download Link to Disk", @"Download Link to Disk context menu item") 				    action:@selector(downloadLinkToDisk:)
+                           toArray:menuItems];
+
+        [self addMenuItemWithTitle:NSLocalizedString(@"Copy Link to Clipboard", @"Copy Link to Clipboard context menu item") 				    action:@selector(copyLinkToClipboard:)
+                           toArray:menuItems];
+
+        [self addMenuItemWithTitle:NSLocalizedString(@"Add Link to Bookmarks", @"Add Link to Bookmarks context menu item") 				    action:@selector(addLinkToBookmarks:)
+                           toArray:menuItems];
+    }
+
+    imageURL = [currentInfo objectForKey:WebContextImageURL];
+
+    if(imageURL){
+        if(linkURL){
+            [menuItems addObject:[NSMenuItem separatorItem]];
+        }
+        [self addMenuItemWithTitle:NSLocalizedString(@"Open Image in New Window", @"Open Image in New Window context menu item") 		            action:@selector(openImageInNewWindow:)
+                           toArray:menuItems];
+        
+        [self addMenuItemWithTitle:NSLocalizedString(@"Download Image To Disk", @"Download Image To Disk context menu item") 				    action:@selector(downloadImageToDisk:)
+                           toArray:menuItems];
+        
+        [self addMenuItemWithTitle:NSLocalizedString(@"Copy Image to Clipboard", @"Copy Image to Clipboard context menu item") 				    action:@selector(copyImageToClipboard:)
+                           toArray:menuItems];
+        
+        [self addMenuItemWithTitle:NSLocalizedString(@"Reload Image", @"Reload Image context menu item") 				                    action:@selector(reloadImage:)
+                           toArray:menuItems];
+    }
+
+    if(!imageURL && !linkURL){
+        WebFrame *webFrame = [currentInfo objectForKey:WebContextFrame];
+
+        if([[webFrame dataSource] isMainDocument]){
+            [self addMenuItemWithTitle:NSLocalizedString(@"View Source", @"View Source context menu item") 				                        action:@selector(viewSource:)
+                               toArray:menuItems];
+            
+            [self addMenuItemWithTitle:NSLocalizedString(@"Save Page", @"Save Page context menu item")
+                                action:@selector(savePage:)
+                               toArray:menuItems];
+        }else{
+            [self addMenuItemWithTitle:NSLocalizedString(@"Open Frame in New Window", @"Open Frame in New Window context menu item") 				action:@selector(openFrameInNewWindow:)
+                               toArray:menuItems];
+            
+            [self addMenuItemWithTitle:NSLocalizedString(@"View Frame Source", @"View Frame Source context menu item") 				                action:@selector(viewSource:)
+                               toArray:menuItems];
+            
+            [self addMenuItemWithTitle:NSLocalizedString(@"Save Frame", @"Save Frame context menu item") 				                        action:@selector(savePage:)
+                               toArray:menuItems];
+        }
+    }
+
+    return menuItems;
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebDefaultContextMenuHandler.h b/WebKit/WebView.subproj/WebDefaultContextMenuHandler.h
index 1cf7f31..c0b1814 100644
--- a/WebKit/WebView.subproj/WebDefaultContextMenuHandler.h
+++ b/WebKit/WebView.subproj/WebDefaultContextMenuHandler.h
@@ -12,7 +12,7 @@
 @protocol WebContextMenuHandler;
 
 @interface WebDefaultContextMenuHandler : NSObject <WebContextMenuHandler> {
-
+    NSDictionary *currentInfo;
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebDefaultContextMenuHandler.m b/WebKit/WebView.subproj/WebDefaultContextMenuHandler.m
index f43589f..4c4cda3 100644
--- a/WebKit/WebView.subproj/WebDefaultContextMenuHandler.m
+++ b/WebKit/WebView.subproj/WebDefaultContextMenuHandler.m
@@ -5,14 +5,92 @@
 
 */
 
-#import "WebDefaultContextMenuHandler.h"
-
+#import <WebKit/WebController.h>
+#import <WebKit/WebDataSource.h>
+#import <WebKit/WebDefaultContextMenuHandler.h>
+#import <WebKit/WebFrame.h>
 
 @implementation WebDefaultContextMenuHandler
 
-- (NSArray *)contextMenuItemsForElementInfo: (NSDictionary *)elementInfo  defaultMenuItems: (NSArray *)menuItems
+- (void)dealloc
+{
+    [currentInfo release];
+    [super dealloc];
+}
+
+- (void)addMenuItemWithTitle:(NSString *)title action:(SEL)selector toArray:(NSMutableArray *)menuItems
 {
-    return nil;
+    NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:title action:selector keyEquivalent:@""];
+    [menuItem setTarget:self];
+    [menuItems addObject:menuItem];
+    [menuItem release];
+}
+
+- (NSArray *)contextMenuItemsForElementInfo: (NSDictionary *)elementInfo  defaultMenuItems: (NSArray *)defaultMenuItems
+{
+    NSMutableArray *menuItems = [NSMutableArray array];
+    NSURL *linkURL, *imageURL;
+    
+    currentInfo = [elementInfo retain];
+
+    linkURL = [currentInfo objectForKey:WebContextLinkURL];
+
+    if(linkURL){
+        [self addMenuItemWithTitle:NSLocalizedString(@"Open Link in New Window", @"Open in New Window context menu item") 				            action:@selector(openInNewWindow:)
+                           toArray:menuItems];
+        
+        [self addMenuItemWithTitle:NSLocalizedString(@"Download Link to Disk", @"Download Link to Disk context menu item") 				    action:@selector(downloadLinkToDisk:)
+                           toArray:menuItems];
+
+        [self addMenuItemWithTitle:NSLocalizedString(@"Copy Link to Clipboard", @"Copy Link to Clipboard context menu item") 				    action:@selector(copyLinkToClipboard:)
+                           toArray:menuItems];
+
+        [self addMenuItemWithTitle:NSLocalizedString(@"Add Link to Bookmarks", @"Add Link to Bookmarks context menu item") 				    action:@selector(addLinkToBookmarks:)
+                           toArray:menuItems];
+    }
+
+    imageURL = [currentInfo objectForKey:WebContextImageURL];
+
+    if(imageURL){
+        if(linkURL){
+            [menuItems addObject:[NSMenuItem separatorItem]];
+        }
+        [self addMenuItemWithTitle:NSLocalizedString(@"Open Image in New Window", @"Open Image in New Window context menu item") 		            action:@selector(openImageInNewWindow:)
+                           toArray:menuItems];
+        
+        [self addMenuItemWithTitle:NSLocalizedString(@"Download Image To Disk", @"Download Image To Disk context menu item") 				    action:@selector(downloadImageToDisk:)
+                           toArray:menuItems];
+        
+        [self addMenuItemWithTitle:NSLocalizedString(@"Copy Image to Clipboard", @"Copy Image to Clipboard context menu item") 				    action:@selector(copyImageToClipboard:)
+                           toArray:menuItems];
+        
+        [self addMenuItemWithTitle:NSLocalizedString(@"Reload Image", @"Reload Image context menu item") 				                    action:@selector(reloadImage:)
+                           toArray:menuItems];
+    }
+
+    if(!imageURL && !linkURL){
+        WebFrame *webFrame = [currentInfo objectForKey:WebContextFrame];
+
+        if([[webFrame dataSource] isMainDocument]){
+            [self addMenuItemWithTitle:NSLocalizedString(@"View Source", @"View Source context menu item") 				                        action:@selector(viewSource:)
+                               toArray:menuItems];
+            
+            [self addMenuItemWithTitle:NSLocalizedString(@"Save Page", @"Save Page context menu item")
+                                action:@selector(savePage:)
+                               toArray:menuItems];
+        }else{
+            [self addMenuItemWithTitle:NSLocalizedString(@"Open Frame in New Window", @"Open Frame in New Window context menu item") 				action:@selector(openFrameInNewWindow:)
+                               toArray:menuItems];
+            
+            [self addMenuItemWithTitle:NSLocalizedString(@"View Frame Source", @"View Frame Source context menu item") 				                action:@selector(viewSource:)
+                               toArray:menuItems];
+            
+            [self addMenuItemWithTitle:NSLocalizedString(@"Save Frame", @"Save Frame context menu item") 				                        action:@selector(savePage:)
+                               toArray:menuItems];
+        }
+    }
+
+    return menuItems;
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index df90c2c..6dfafb9 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -219,7 +219,6 @@
     
     point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
     elementInfo = [self _elementInfoAtPoint:point];
-    //NSLog([elementInfo description]);
 
     defaultContextMenuHandler = [[self _controller] _defaultContextMenuHandler];
     defaultMenuItems = [defaultContextMenuHandler contextMenuItemsForElementInfo: elementInfo  defaultMenuItems: nil];
@@ -237,7 +236,7 @@
         [menu addItem:[menuItems objectAtIndex:i]];
     }
         
-    return nil;
+    return menu;
 }
 
 - (void)setContextMenusEnabled: (BOOL)flag

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list