[webkit-changes] cvs commit: WebKit/WebView.subproj WebPDFView.m

John sullivan at opensource.apple.com
Fri Jul 1 14:30:52 PDT 2005


sullivan    05/07/01 14:30:52

  Modified:    .        ChangeLog
               WebView.subproj WebPDFView.m
  Log:
          Reviewed by Darin Adler.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=3711: Displayed PDF have limited options in contextual menu
  
          This was a problem with using Tiger's version of Safari with tip of tree WebKit.
  
          * WebView.subproj/WebPDFView.m:
          (-[WebPDFView _anyPDFTagsFoundInMenu:]):
          new method, returns YES if the menu contains any items with any of the new PDF-related tags.
          (-[WebPDFView menuForEvent:]):
          If the executable was linked on Tiger or older (but it will never be older, since this code is
          new to Tiger), force all of the PDF-related items into the menu if none of them were there
          after processing by the delegate.
  
  Revision  Changes    Path
  1.3210    +16 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3209
  retrieving revision 1.3210
  diff -u -r1.3209 -r1.3210
  --- ChangeLog	1 Jul 2005 05:20:43 -0000	1.3209
  +++ ChangeLog	1 Jul 2005 21:30:50 -0000	1.3210
  @@ -1,3 +1,19 @@
  +2005-07-01  John Sullivan  <sullivan at apple.com>
  +
  +        Reviewed by Darin Adler.
  +        
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=3711: Displayed PDF have limited options in contextual menu
  +        
  +        This was a problem with using Tiger's version of Safari with tip of tree WebKit.
  +
  +        * WebView.subproj/WebPDFView.m:
  +        (-[WebPDFView _anyPDFTagsFoundInMenu:]):
  +        new method, returns YES if the menu contains any items with any of the new PDF-related tags.
  +        (-[WebPDFView menuForEvent:]):
  +        If the executable was linked on Tiger or older (but it will never be older, since this code is
  +        new to Tiger), force all of the PDF-related items into the menu if none of them were there 
  +        after processing by the delegate.
  +
   2005-06-30  Darin Adler  <darin at apple.com>
   
           Reviewed by John Sullivan.
  
  
  
  1.15      +47 -1     WebKit/WebView.subproj/WebPDFView.m
  
  Index: WebPDFView.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebPDFView.m,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- WebPDFView.m	22 Jun 2005 21:32:09 -0000	1.14
  +++ WebPDFView.m	1 Jul 2005 21:30:52 -0000	1.15
  @@ -39,6 +39,7 @@
   #import <WebKit/WebView.h>
   #import <WebKit/WebViewPrivate.h>
   
  +#import <WebKitSystemInterface.h>
   #import <Quartz/Quartz.h>
   
   // QuartzPrivate.h doesn't include the PDFKit private headers, so we can't get at PDFViewPriv.h. (3957971)
  @@ -230,6 +231,28 @@
       return copiedItems;
   }
   
  +- (BOOL)_anyPDFTagsFoundInMenu:(NSMenu *)menu
  +{
  +    NSEnumerator *e = [[menu itemArray] objectEnumerator];
  +    NSMenuItem *item;
  +    while ((item = [e nextObject]) != nil) {
  +        switch ([item tag]) {
  +            case WebMenuItemTagOpenWithDefaultApplication:
  +            case WebMenuItemPDFActualSize:
  +            case WebMenuItemPDFZoomIn:
  +            case WebMenuItemPDFZoomOut:
  +            case WebMenuItemPDFAutoSize:
  +            case WebMenuItemPDFSinglePage:
  +            case WebMenuItemPDFFacingPages:
  +            case WebMenuItemPDFContinuous:
  +            case WebMenuItemPDFNextPage:
  +            case WebMenuItemPDFPreviousPage:
  +                return YES;
  +        }
  +    }
  +    return NO;
  +}
  +
   - (NSMenu *)menuForEvent:(NSEvent *)theEvent
   {
       // Start with the menu items supplied by PDFKit, with WebKit tags applied
  @@ -258,7 +281,30 @@
       ASSERT(webView);
       // Currently clicks anywhere in the PDF view are treated the same, so we just pass NSZeroPoint;
       // we implement elementAtPoint: here just to be slightly forward-looking.
  -    return [webView _menuForElement:[self elementAtPoint:NSZeroPoint] defaultItems:items];
  +    NSMenu *menu = [webView _menuForElement:[self elementAtPoint:NSZeroPoint] defaultItems:items];
  +    
  +    // The delegate has now had the opportunity to add items to the standard PDF-related items, or to
  +    // remove or modify some of the PDF-related items. In 10.4, the PDF context menu did not go through 
  +    // the standard WebKit delegate path, and so the standard PDF-related items always appeared. For
  +    // clients that create their own context menu by hand-picking specific items from the default list, such as
  +    // Safari, none of the PDF-related items will appear until the client is rewritten to explicitly
  +    // include these items. So for backwards compatibility we're going to include the entire set of PDF-related
  +    // items if the executable was linked in 10.4 or earlier and the menu returned from the delegate mechanism
  +    // contains none of the PDF-related items.
  +    if (WKExecutableLinkedInTigerOrEarlier()) {
  +        if (![self _anyPDFTagsFoundInMenu:menu]) {
  +            [menu addItem:[NSMenuItem separatorItem]];
  +            NSEnumerator *e = [items objectEnumerator];
  +            NSMenuItem *menuItem;
  +            while ((menuItem = [e nextObject]) != nil) {
  +                // copy menuItem since a given menuItem can be in only one menu at a time, and we don't
  +                // want to mess with the menu returned from PDFKit.
  +                [menu addItem:[menuItem copy]];
  +            }
  +        }
  +    }
  +    
  +    return menu;
   }
   
   - (void)_updateScalingToReflectTextSize
  
  
  



More information about the webkit-changes mailing list