Changeset 83004 in webkit


Ignore:
Timestamp:
Apr 5, 2011 5:55:34 PM (13 years ago)
Author:
Darin Adler
Message:

2011-04-05 Darin Adler <Darin Adler>

Reviewed by Alexey Proskuryakov.

[Mac] WebKit2: Escape key does not stop page loads when focus is on the web page
https://bugs.webkit.org/show_bug.cgi?id=57893
<rdar://problem/9130486>

  • UIProcess/API/mac/PageClientImpl.h: Added executeSavedCommandBySelector.
  • UIProcess/API/mac/PageClientImpl.mm: Renamed internal Objective-C classes to use the WebKit2 Objective-C class prefix, WK, rather than the WebKit1 Objective-C class prefix, Web. Removed some unneeded explicit WebKit namespace prefixes. (-[WKEditCommandObjC initWithWebEditCommandProxy:]): Removed unneeded WebKit namespace prefix. (-[WKEditCommandObjC command]): Ditto. (-[WKEditorUndoTargetObjC undoEditing:]): Updated for new class name. (-[WKEditorUndoTargetObjC redoEditing:]): Ditto. (WebKit::PageClientImpl::PageClientImpl): Ditto. (WebKit::PageClientImpl::registerEditCommand): Ditto. (WebKit::PageClientImpl::executeSavedCommandBySelector): Added.
  • UIProcess/API/mac/WKView.mm: Renamed internal Objective-C categories to use the WebKit2 Objective-C prefix, WK, rather than the WebKit1 Objective-C prefix, Web, or no prefix at all. Tweaked use of extern "C" a little. (-[WKView doCommandBySelector:]): Tweaked the comment. (-[WKView _executeSavedCommandBySelector:]): Added. For use when command is not handled by WebCore. (-[WKResponderChainSink initWithResponderChain:]): Added. Based on the WebResponderChainSink class in WebKit1. (-[WKResponderChainSink detach]): Added. (-[WKResponderChainSink didReceiveUnhandledCommand]): Added. (-[WKResponderChainSink noResponderFor:]): Added. (-[WKResponderChainSink doCommandBySelector:]): Added. (-[WKResponderChainSink tryToPerform:with:]): Added.
  • UIProcess/API/mac/WKViewInternal.h: Added declaration of _executeSavedCommandBySelector: method. Also removed unneeded includes.
  • UIProcess/PageClient.h: Added executeSavedCommandBySelector.
  • UIProcess/WebPageProxy.h: Added executeSavedCommandBySelector.
  • UIProcess/WebPageProxy.messages.in: Added ExecuteSavedCommandBySelector.
  • UIProcess/mac/WebFullScreenManagerProxyMac.mm: Updated includes.
  • UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::executeSavedCommandBySelector): Added.
  • WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::executeKeypressCommandsInternal): Send the synchronous ExecuteSavedCommandBySelector message when a command is not handled by WebCore.
Location:
trunk/Source/WebKit2
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r82997 r83004  
     12011-04-05  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        [Mac] WebKit2: Escape key does not stop page loads when focus is on the web page
     6        https://bugs.webkit.org/show_bug.cgi?id=57893
     7        <rdar://problem/9130486>
     8
     9        * UIProcess/API/mac/PageClientImpl.h: Added executeSavedCommandBySelector.
     10        * UIProcess/API/mac/PageClientImpl.mm: Renamed internal Objective-C classes to use
     11        the WebKit2 Objective-C class prefix, WK, rather than the WebKit1 Objective-C class
     12        prefix, Web. Removed some unneeded explicit WebKit namespace prefixes.
     13        (-[WKEditCommandObjC initWithWebEditCommandProxy:]): Removed unneeded WebKit
     14        namespace prefix.
     15        (-[WKEditCommandObjC command]): Ditto.
     16        (-[WKEditorUndoTargetObjC undoEditing:]): Updated for new class name.
     17        (-[WKEditorUndoTargetObjC redoEditing:]): Ditto.
     18        (WebKit::PageClientImpl::PageClientImpl): Ditto.
     19        (WebKit::PageClientImpl::registerEditCommand): Ditto.
     20        (WebKit::PageClientImpl::executeSavedCommandBySelector): Added.
     21
     22        * UIProcess/API/mac/WKView.mm: Renamed internal Objective-C categories to use the
     23        WebKit2 Objective-C prefix, WK, rather than the WebKit1 Objective-C prefix, Web,
     24        or no prefix at all. Tweaked use of extern "C" a little.
     25        (-[WKView doCommandBySelector:]): Tweaked the comment.
     26        (-[WKView _executeSavedCommandBySelector:]): Added. For use when command is not handled
     27        by WebCore.
     28        (-[WKResponderChainSink initWithResponderChain:]): Added. Based on the
     29        WebResponderChainSink class in WebKit1.
     30        (-[WKResponderChainSink detach]): Added.
     31        (-[WKResponderChainSink didReceiveUnhandledCommand]): Added.
     32        (-[WKResponderChainSink noResponderFor:]): Added.
     33        (-[WKResponderChainSink doCommandBySelector:]): Added.
     34        (-[WKResponderChainSink tryToPerform:with:]): Added.
     35
     36        * UIProcess/API/mac/WKViewInternal.h: Added declaration of _executeSavedCommandBySelector:
     37        method. Also removed unneeded includes.
     38
     39        * UIProcess/PageClient.h: Added executeSavedCommandBySelector.
     40        * UIProcess/WebPageProxy.h: Added executeSavedCommandBySelector.
     41        * UIProcess/WebPageProxy.messages.in: Added ExecuteSavedCommandBySelector.
     42
     43        * UIProcess/mac/WebFullScreenManagerProxyMac.mm: Updated includes.
     44
     45        * UIProcess/mac/WebPageProxyMac.mm:
     46        (WebKit::WebPageProxy::executeSavedCommandBySelector): Added.
     47
     48        * WebProcess/WebPage/mac/WebPageMac.mm:
     49        (WebKit::WebPage::executeKeypressCommandsInternal): Send the synchronous
     50        ExecuteSavedCommandBySelector message when a command is not handled by WebCore.
     51
    1522011-04-05  Anders Carlsson  <andersca@apple.com>
    253
  • trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h

    r82717 r83004  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7373    virtual void clearAllEditCommands();
    7474    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, const TextInputState&, Vector<WebCore::KeypressCommand>&);
     75    virtual bool executeSavedCommandBySelector(const String& selector);
    7576    virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
    7677
  • trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm

    r82717 r83004  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5353
    5454using namespace WebCore;
    55 
    56 @interface WebEditCommandObjC : NSObject
    57 {
    58     RefPtr<WebKit::WebEditCommandProxy> m_command;
    59 }
    60 
    61 - (id)initWithWebEditCommandProxy:(PassRefPtr<WebKit::WebEditCommandProxy>)command;
    62 - (WebKit::WebEditCommandProxy*)command;
    63 
     55using namespace WebKit;
     56
     57@interface WKEditCommandObjC : NSObject
     58{
     59    RefPtr<WebEditCommandProxy> m_command;
     60}
     61- (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command;
     62- (WebEditCommandProxy*)command;
    6463@end
    6564
    66 @implementation WebEditCommandObjC
    67 
    68 - (id)initWithWebEditCommandProxy:(PassRefPtr<WebKit::WebEditCommandProxy>)command
     65@interface WKEditorUndoTargetObjC : NSObject
     66- (void)undoEditing:(id)sender;
     67- (void)redoEditing:(id)sender;
     68@end
     69
     70@implementation WKEditCommandObjC
     71
     72- (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command
    6973{
    7074    self = [super init];
     
    7680}
    7781
    78 - (WebKit::WebEditCommandProxy*)command
     82- (WebEditCommandProxy*)command
    7983{
    8084    return m_command.get();
     
    8387@end
    8488
    85 @interface WebEditorUndoTargetObjC : NSObject
    86 
    87 - (void)undoEditing:(id)sender;
    88 - (void)redoEditing:(id)sender;
    89 
    90 @end
    91 
    92 @implementation WebEditorUndoTargetObjC
     89@implementation WKEditorUndoTargetObjC
    9390
    9491- (void)undoEditing:(id)sender
    9592{
    96     ASSERT([sender isKindOfClass:[WebEditCommandObjC class]]);
     93    ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]);
    9794    [sender command]->unapply();
    9895}
     
    10097- (void)redoEditing:(id)sender
    10198{
    102     ASSERT([sender isKindOfClass:[WebEditCommandObjC class]]);
     99    ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]);
    103100    [sender command]->reapply();
    104101}
     
    120117PageClientImpl::PageClientImpl(WKView* wkView)
    121118    : m_wkView(wkView)
    122     , m_undoTarget(AdoptNS, [[WebEditorUndoTargetObjC alloc] init])
     119    , m_undoTarget(AdoptNS, [[WKEditorUndoTargetObjC alloc] init])
    123120{
    124121}
     
    278275    RefPtr<WebEditCommandProxy> command = prpCommand;
    279276
    280     RetainPtr<WebEditCommandObjC> commandObjC(AdoptNS, [[WebEditCommandObjC alloc] initWithWebEditCommandProxy:command]);
     277    RetainPtr<WKEditCommandObjC> commandObjC(AdoptNS, [[WKEditCommandObjC alloc] initWithWebEditCommandProxy:command]);
    281278    NSString *actionName = nameForEditAction(command->editAction());
    282279
     
    484481}
    485482
     483bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
     484{
     485    return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)];
     486}
     487
    486488} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r82870 r83004  
    7171#import <wtf/RetainPtr.h>
    7272
    73 @interface NSApplication (WebNSApplicationDetails)
     73@interface NSApplication (WKNSApplicationDetails)
    7474- (void)speakString:(NSString *)string;
    7575- (void)_setCurrentEvent:(NSEvent *)event;
    7676@end
    7777
    78 @interface NSWindow (WebNSWindowDetails)
     78@interface NSObject (WKNSTextInputContextDetails)
     79- (BOOL)wantsToHandleMouseEvents;
     80- (BOOL)handleMouseEvent:(NSEvent *)event;
     81@end
     82
     83@interface NSWindow (WKNSWindowDetails)
    7984- (NSRect)_growBoxRect;
    8085- (id)_growBoxOwner;
     
    8388@end
    8489
    85 extern "C" {
    86     // Need to declare this attribute name because AppKit exports it but does not make it available in API or SPI headers.
    87     // FIXME: We wouldn't need this if we implemented NSTextInputClient protocol instead of deprecated NSTextInput.
    88     extern NSString *NSTextInputReplacementRangeAttributeName;
    89 }
     90// Declare this attribute name because AppKit exports it but does not make it available in API or SPI headers.
     91// FIXME: We wouldn't need this if we implemented the NSTextInputClient protocol instead of the deprecated NSTextInput.
     92extern "C" NSString *NSTextInputReplacementRangeAttributeName;
    9093
    9194using namespace WebKit;
     
    157160@end
    158161
     162@interface WKResponderChainSink : NSResponder {
     163    NSResponder *_lastResponderInChain;
     164    bool _didReceiveUnhandledCommand;
     165}
     166- (id)initWithResponderChain:(NSResponder *)chain;
     167- (void)detach;
     168- (bool)didReceiveUnhandledCommand;
     169@end
     170
    159171@implementation WKViewData
    160 @end
    161 
    162 @interface NSObject (NSTextInputContextDetails)
    163 - (BOOL)wantsToHandleMouseEvents;
    164 - (BOOL)handleMouseEvent:(NSEvent *)event;
    165172@end
    166173
     
    10321039        parameters->commands->append(KeypressCommand(NSStringFromSelector(selector)));
    10331040    else {
    1034         // FIXME: Send the command to Editor synchronously.
     1041        // FIXME: Send the command to Editor synchronously and only send it along the
     1042        // responder chain if it's a selector that does not correspond to an editing command.
    10351043        [super doCommandBySelector:selector];
    10361044    }
     
    21732181#endif
    21742182
     2183- (bool)_executeSavedCommandBySelector:(SEL)selector
     2184{
     2185    // The sink does two things: 1) Tells us if the responder went unhandled, and
     2186    // 2) prevents any NSBeep; we don't ever want to beep here.
     2187    RetainPtr<WKResponderChainSink> sink(AdoptNS, [[WKResponderChainSink alloc] initWithResponderChain:self]);
     2188    [super doCommandBySelector:selector];
     2189    [sink.get() detach];
     2190    return ![sink.get() didReceiveUnhandledCommand];
     2191}
     2192
    21752193@end
    21762194
     
    22212239@end
    22222240
     2241@implementation WKResponderChainSink
     2242
     2243- (id)initWithResponderChain:(NSResponder *)chain
     2244{
     2245    self = [super init];
     2246    if (!self)
     2247        return nil;
     2248    _lastResponderInChain = chain;
     2249    while (NSResponder *next = [_lastResponderInChain nextResponder])
     2250        _lastResponderInChain = next;
     2251    [_lastResponderInChain setNextResponder:self];
     2252    return self;
     2253}
     2254
     2255- (void)detach
     2256{
     2257    [_lastResponderInChain setNextResponder:nil];
     2258    _lastResponderInChain = nil;
     2259}
     2260
     2261- (bool)didReceiveUnhandledCommand
     2262{
     2263    return _didReceiveUnhandledCommand;
     2264}
     2265
     2266- (void)noResponderFor:(SEL)selector
     2267{
     2268    _didReceiveUnhandledCommand = true;
     2269}
     2270
     2271- (void)doCommandBySelector:(SEL)selector
     2272{
     2273    _didReceiveUnhandledCommand = true;
     2274}
     2275
     2276- (BOOL)tryToPerform:(SEL)action with:(id)object
     2277{
     2278    _didReceiveUnhandledCommand = true;
     2279    return YES;
     2280}
     2281
     2282@end
  • trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h

    r82717 r83004  
    2525
    2626#import "WKView.h"
    27 #import <WebCore/Editor.h>
    28 #import <WebCore/KeyboardEvent.h>
     27#import <wtf/Forward.h>
     28#import <wtf/Vector.h>
    2929
    3030namespace CoreIPC {
    3131    class DataReference;
     32}
     33
     34namespace WebCore {
     35    struct KeypressCommand;
    3236}
    3337
     
    3943}
    4044
    41 #if ENABLE(FULLSCREEN_API)
    4245@class WKFullScreenWindowController;
    43 #endif
    4446
    4547@interface WKView (Internal)
     
    5557- (BOOL)_interpretKeyEvent:(NSEvent *)theEvent withCachedTextInputState:(const WebKit::TextInputState&)cachedTextInputState savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands;
    5658- (void)_resendKeyDownEvent:(NSEvent *)event;
     59- (bool)_executeSavedCommandBySelector:(SEL)selector;
    5760- (NSRect)_convertToDeviceSpace:(NSRect)rect;
    5861- (NSRect)_convertToUserSpace:(NSRect)rect;
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r82929 r83004  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    102102    virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&) = 0;
    103103    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, const TextInputState&, Vector<WebCore::KeypressCommand>&) = 0;
     104    virtual bool executeSavedCommandBySelector(const String& selector) = 0;
    104105    virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
    105106#endif
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r82929 r83004  
    594594#if PLATFORM(MAC)
    595595    void interpretQueuedKeyEvent(const TextInputState&, bool& handled, Vector<WebCore::KeypressCommand>&);
     596    void executeSavedCommandBySelector(const String& selector, bool& handled);
    596597#endif
    597598
    598599#if PLATFORM(GTK)
    599     void getEditorCommandsForKeyEvent(Vector<WTF::String>&);
     600    void getEditorCommandsForKeyEvent(Vector<String>&);
    600601#endif
    601602
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r82936 r83004  
    200200    # Keyboard input support messages
    201201    InterpretQueuedKeyEvent(WebKit::TextInputState state) -> (bool handled, Vector<WebCore::KeypressCommand> savedCommands)
    202    
     202    ExecuteSavedCommandBySelector(WTF::String selector) -> (bool handled)
     203
    203204    # Remote accessibility messages
    204205    RegisterWebProcessAccessibilityToken(CoreIPC::DataReference data)
  • trunk/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm

    r80924 r83004  
    2424 */
    2525
    26 #include "config.h"
    27 #include "WebFullScreenManagerProxy.h"
    28 #include "LayerTreeContext.h"
    29 #include "WKFullScreenWindowController.h"
    30 #include "WKViewInternal.h"
     26#import "config.h"
     27#import "WebFullScreenManagerProxy.h"
     28
     29#import "LayerTreeContext.h"
     30#import "WKFullScreenWindowController.h"
     31#import "WKViewInternal.h"
     32#import <WebCore/IntRect.h>
    3133
    3234#if ENABLE(FULLSCREEN_API)
  • trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm

    r82779 r83004  
    284284}
    285285
     286void WebPageProxy::executeSavedCommandBySelector(const String& selector, bool& handled)
     287{
     288    handled = m_pageClient->executeSavedCommandBySelector(selector);
     289}
     290
    286291} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r82853 r83004  
    153153            if (command.isSupported())
    154154                eventWasHandled |= command.execute(event);
    155             // FIXME: WebHTMLView sends the event up the responder chain with WebResponderChainSink if it's not supported by the editor. Should we do the same?
     155            else {
     156                bool eventWasHandledByUIProcess = false;
     157                WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ExecuteSavedCommandBySelector(commands[i].commandName),
     158                    Messages::WebPageProxy::ExecuteSavedCommandBySelector::Reply(eventWasHandledByUIProcess), m_pageID);
     159                eventWasHandled |= eventWasHandledByUIProcess;
     160            }
    156161        }
    157162    }
Note: See TracChangeset for help on using the changeset viewer.