Changeset 19469 in webkit


Ignore:
Timestamp:
Feb 7, 2007 11:48:13 AM (17 years ago)
Author:
sullivan
Message:

Reviewed by Darin

  • added some clarity to some menu-handling shenanigans
  • WebCoreSupport/WebContextMenuClient.mm: (fixMenusToSendToOldClients): renamed from fixMenusForOldClients; added comments, FIXME, and assertion (fixMenusReceivedFromOldClients): renamed from fixMenusFromOldClients; added comments, FIXME, and assertion (WebContextMenuClient::getCustomMenuFromDefaultItems): updated for name changes
Location:
trunk/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/ChangeLog

    r19458 r19469  
     12007-02-07  John Sullivan  <sullivan@apple.com>
     2
     3        Reviewed by Darin
     4
     5        - added some clarity to some menu-handling shenanigans
     6
     7        * WebCoreSupport/WebContextMenuClient.mm:
     8        (fixMenusToSendToOldClients):
     9        renamed from fixMenusForOldClients; added comments, FIXME, and assertion
     10        (fixMenusReceivedFromOldClients):
     11        renamed from fixMenusFromOldClients; added comments, FIXME, and assertion
     12        (WebContextMenuClient::getCustomMenuFromDefaultItems):
     13        updated for name changes
     14
    1152007-02-06  Kevin Decker <kdecker@apple.com>
    216
  • trunk/WebKit/WebCoreSupport/WebContextMenuClient.mm

    r19409 r19469  
    5959}
    6060
    61 static NSMutableArray *fixMenusForOldClients(NSMutableArray *defaultMenuItems)
    62 {
    63     // Here we change all SPI tags listed in WebUIDelegatePrivate.h to WebMenuItemTagOther
     61static NSMutableArray *fixMenusToSendToOldClients(NSMutableArray *defaultMenuItems)
     62{
     63    // Here we change all editing-related SPI tags listed in WebUIDelegatePrivate.h to WebMenuItemTagOther
    6464    // to match our old WebKit context menu behavior.
     65
     66    // FIXME 4950029: This is a temporary solution to make Mail's context menus continue working until
     67    // they've updated their code to expect the new tags. We'll have to coordinate a WebKit update with
     68    // that Mail update to start sending the new tags again. At that point, this code should be changed
     69    // to run only for clients that were linked against old versions of WebKit.
    6570   
    6671    unsigned defaultItemsCount = [defaultMenuItems count];
     
    6974        if ([item tag] >= WEBMENUITEMTAG_SPI_START)
    7075            [item setTag:WebMenuItemTagOther];
     76        else {
     77            // All items should have useful tags coming into this method.
     78            ASSERT([item tag] != WebMenuItemTagOther);
     79        }
    7180    }
    7281   
     
    7483}
    7584
    76 static NSMutableArray *fixMenusFromOldClients(NSMutableArray *newMenuItems, NSMutableArray *defaultMenuItems)
     85static NSMutableArray *fixMenusReceivedFromOldClients(NSMutableArray *newMenuItems, NSMutableArray *defaultMenuItems)
    7786{   
    7887    // The WebMenuItemTag enum has changed since Tiger, so clients built against Tiger WebKit might reference incorrect values for tags.
     
    108117    }
    109118   
     119    // Restore the new-style tags to the editing-related menu items. This is the 2nd part of the
     120    // workaround whose first part is in fixMenusToSendToOldClients.
     121   
     122    // FIXME 4950029: This is a temporary solution to make Mail's context menus continue working until
     123    // they've updated their code to expect the new tags. We'll have to coordinate a WebKit update with
     124    // that Mail update to start sending the new tags again. At that point, this code should be changed
     125    // to run only for clients that were linked against old versions of WebKit.
    110126    unsigned defaultItemsCount = [defaultMenuItems count];
    111127    for (unsigned i = 0; i < defaultItemsCount; ++i) {
    112128        NSMenuItem *item = [defaultMenuItems objectAtIndex:i];
     129        // Items with a useful tag can be left alone. Items with WebMenuItemTagOther should be only the
     130        // ones whose tags we changed in fixMenusToSendToOldClients.
    113131        if ([item tag] != WebMenuItemTagOther)
    114132            continue;
     
    160178        else if (title == [[WebViewFactory sharedFactory] contextMenuItemTagRightToLeft])
    161179            [item setTag:WebMenuItemTagRightToLeft];
     180        else {
     181            // We don't expect WebMenuItemTagOther for any items other than the ones we explicitly handle
     182            ASSERT_NOT_REACHED();
     183        }
    162184    }
    163185
     
    172194   
    173195    NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:defaultMenu->hitTestResult()] autorelease];
    174     NSMutableArray *defaultMenuItems = fixMenusForOldClients(defaultMenu->platformDescription());
     196    NSMutableArray *defaultMenuItems = fixMenusToSendToOldClients(defaultMenu->platformDescription());
    175197    NSMutableArray *newMenuItems = [[delegate webView:m_webView contextMenuItemsForElement:element defaultMenuItems:defaultMenuItems] mutableCopy];
    176198
    177     return fixMenusFromOldClients(newMenuItems, defaultMenuItems);
     199    return fixMenusReceivedFromOldClients(newMenuItems, defaultMenuItems);
    178200}
    179201
Note: See TracChangeset for help on using the changeset viewer.