Changeset 21240 in webkit


Ignore:
Timestamp:
May 3, 2007 4:08:28 PM (17 years ago)
Author:
thatcher
Message:

Reviewed by Kevin.

<rdar://problem/4975212> REGRESSION: With NetNewsWire 2.1.1, the contextual menu shows extra menu items when focus
is placed in input or textarea field

The NetNewsWire UI delegate isn't expecting calls for form controls, so we need to do a linked-on-or-after check.
If the application was linked against Tiger or earlier and the element is a text form control, just return the
default menu items and bypass the delegate call completely.

  • WebCoreSupport/WebContextMenuClient.mm: (isPreVersion3Client): Cache the result of the WebKitLinkedOnOrAfter call (fixMenusToSendToOldClients): Call the new isPreVersion3Client() (fixMenusReceivedFromOldClients): Ditto. (WebContextMenuClient::getCustomMenuFromDefaultItems): Return the default menu items if the element is a text form control.
Location:
trunk/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/ChangeLog

    r21238 r21240  
     12007-05-03  TImothy Hatcher  <timothy@apple.com>
     2
     3        Reviewed by Kevin.
     4
     5        <rdar://problem/4975212> REGRESSION: With NetNewsWire 2.1.1, the contextual menu shows extra menu items when focus
     6        is placed in input or textarea field
     7
     8        The NetNewsWire UI delegate isn't expecting calls for form controls, so we need to do a linked-on-or-after check.
     9        If the application was linked against Tiger or earlier and the element is a text form control, just return the
     10        default menu items and bypass the delegate call completely.
     11
     12        * WebCoreSupport/WebContextMenuClient.mm:
     13        (isPreVersion3Client): Cache the result of the WebKitLinkedOnOrAfter call
     14        (fixMenusToSendToOldClients): Call the new isPreVersion3Client()
     15        (fixMenusReceivedFromOldClients): Ditto.
     16        (WebContextMenuClient::getCustomMenuFromDefaultItems): Return the default menu items if the element is a text form control.
     17
    1182007-05-03  Mark Rowe  <mrowe@apple.com>
    219
  • trunk/WebKit/WebCoreSupport/WebContextMenuClient.mm

    r21234 r21240  
    4343#import <WebCore/ContextMenu.h>
    4444#import <WebCore/KURL.h>
     45#import <WebKit/DOMPrivate.h>
    4546
    4647using namespace WebCore;
     
    6566}
    6667
     68static BOOL isPreVersion3Client(void)
     69{
     70    static BOOL preVersion3Client = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_3_0_CONTEXT_MENU_TAGS);
     71    return preVersion3Client;
     72}
     73
    6774static void fixMenusToSendToOldClients(NSMutableArray *defaultMenuItems)
    6875{
    69     BOOL preVersion3Client = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_3_0_CONTEXT_MENU_TAGS);
     76    BOOL preVersion3Client = isPreVersion3Client();
    7077    if (!preVersion3Client)
    7178        return;
     
    121128static void fixMenusReceivedFromOldClients(NSMutableArray *newMenuItems)
    122129{   
    123     BOOL preVersion3Client = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_3_0_CONTEXT_MENU_TAGS);
     130    BOOL preVersion3Client = isPreVersion3Client();
    124131    if (!preVersion3Client)
    125132        return;
     
    216223    if (![delegate respondsToSelector:@selector(webView:contextMenuItemsForElement:defaultMenuItems:)])
    217224        return defaultMenu->platformDescription();
    218    
     225
    219226    NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:defaultMenu->hitTestResult()] autorelease];
     227
     228    BOOL preVersion3Client = isPreVersion3Client();
     229    if (preVersion3Client) {
     230        DOMNode *node = [element objectForKey:WebElementDOMNodeKey];
     231        if ([node isKindOfClass:[DOMHTMLInputElement class]] && [(DOMHTMLInputElement *)node _isTextField])
     232            return defaultMenu->platformDescription();
     233        if ([node isKindOfClass:[DOMHTMLTextAreaElement class]])
     234            return defaultMenu->platformDescription();
     235    }
     236
    220237    NSMutableArray *defaultMenuItems = defaultMenu->platformDescription();
    221238   
Note: See TracChangeset for help on using the changeset viewer.