Changeset 18012 in webkit


Ignore:
Timestamp:
Dec 4, 2006 5:29:07 PM (17 years ago)
Author:
darin
Message:

LayoutTests:

Reviewed by Adele.

  • test the part of http://bugs.webkit.org/show_bug.cgi?id=11628 REGRESSION (r17597): Command-return in text fields doesn't open a new tab or window that can easily be tested from the DOM -- this only checks that simulated mouse events from clicking on a link have the key state from the Enter key keyboard event, which is one part of the fix for the bug above
  • fast/events/simulated-key-state-expected.txt: Added.
  • fast/events/simulated-key-state.html: Added.

WebCore:

Reviewed by Adele.

This fixes command-return when the focus is on a link.
Despite the title of the bug, Mitz wanted me to fix both, and I will not
say no to him!

Test: fast/events/simulated-key-state.html

  • dom/EventTargetNode.cpp: (WebCore::EventTargetNode::dispatchSimulatedMouseEvent): Instead of always passing false for all the key state in simulated mouse events, pass the state from the first underlying event in the chain that has key state; in the case in the bug, the keyboard event will be the underlying event itself and we'll propagate the alt key modifier to the mouse event, resulting in the effect we want. It's nice that JavaScript also gets to see the proper modifiers in the mouse event.
  • html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::defaultEventHandler): Added code to pass in an underlying event to dispatchSimulatedClick. After looking at all the other callers, this seems to be the only one that needs to pass an event that is currently passing 0. Also removed the code that only simulated a click when the event has a PlatformKeyboardEvent -- no reason for that and it prevented me from writing a layout test for the fix.
  • dom/UIEventWithKeyState.h: Added findEventWithKeyState function that walks the underlyingEvent chain to find the first event that has key state. This already existed in WebKit, but I wanted to use it in dispatchSimulatedMouseEvent.
  • dom/UIEventWithKeyState.cpp: Added.
  • CMakeLists.txt: Added UIEventWithKeyState.cpp.
  • WebCore.vcproj/WebCore/WebCore.vcproj: Added UIEventWithKeyState.cpp.
  • WebCore.xcodeproj/project.pbxproj: Added UIEventWithKeyState.cpp.
  • WebCoreSources.bkl: Added UIEventWithKeyState.cpp.
  • WebCore.exp: Added findEventWithKeyState, used by WebKit.

WebKit:

Reviewed by Adele.

  • WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::actionDictionary): Changed to use the new findEventWithKeyState function in WebCore instead of a local function in this file.
Location:
trunk
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r18009 r18012  
     12006-12-04  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Adele.
     4
     5        - test the part of http://bugs.webkit.org/show_bug.cgi?id=11628
     6          REGRESSION (r17597): Command-return in text fields doesn't open a new tab or window
     7          that can easily be tested from the DOM -- this only checks that
     8          simulated mouse events from clicking on a link have the key state
     9          from the Enter key keyboard event, which is one part of the fix
     10          for the bug above
     11
     12        * fast/events/simulated-key-state-expected.txt: Added.
     13        * fast/events/simulated-key-state.html: Added.
     14
    1152006-12-02  Geoffrey Garen  <ggaren@apple.com>
    216
  • trunk/WebCore/CMakeLists.txt

    r17993 r18012  
    797797    dom/TreeWalker.cpp
    798798    dom/UIEvent.cpp
     799    dom/UIEventWithKeyState.cpp
    799800    dom/WheelEvent.cpp
    800801    dom/XMLTokenizer.cpp
  • trunk/WebCore/ChangeLog

    r18011 r18012  
     12006-12-04  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Adele.
     4
     5        - fix another part of http://bugs.webkit.org/show_bug.cgi?id=11628
     6          REGRESSION (r17597): Command-return in text fields doesn't open a new tab or window
     7
     8        This fixes command-return when the focus is on a link.
     9        Despite the title of the bug, Mitz wanted me to fix both, and I will not
     10        say no to him!
     11
     12        Test: fast/events/simulated-key-state.html
     13
     14        * dom/EventTargetNode.cpp:
     15        (WebCore::EventTargetNode::dispatchSimulatedMouseEvent): Instead of always passing
     16        false for all the key state in simulated mouse events, pass the state from the
     17        first underlying event in the chain that has key state; in the case in the bug,
     18        the keyboard event will be the underlying event itself and we'll propagate the
     19        alt key modifier to the mouse event, resulting in the effect we want. It's nice
     20        that JavaScript also gets to see the proper modifiers in the mouse event.
     21
     22        * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::defaultEventHandler):
     23        Added code to pass in an underlying event to dispatchSimulatedClick. After looking
     24        at all the other callers, this seems to be the only one that needs to pass an
     25        event that is currently passing 0. Also removed the code that only simulated a
     26        click when the event has a PlatformKeyboardEvent -- no reason for that and it
     27        prevented me from writing a layout test for the fix.
     28
     29        * dom/UIEventWithKeyState.h: Added findEventWithKeyState function that walks the
     30        underlyingEvent chain to find the first event that has key state. This already
     31        existed in WebKit, but I wanted to use it in dispatchSimulatedMouseEvent.
     32        * dom/UIEventWithKeyState.cpp: Added.
     33
     34        * CMakeLists.txt: Added UIEventWithKeyState.cpp.
     35        * WebCore.vcproj/WebCore/WebCore.vcproj: Added UIEventWithKeyState.cpp.
     36        * WebCore.xcodeproj/project.pbxproj: Added UIEventWithKeyState.cpp.
     37        * WebCoreSources.bkl: Added UIEventWithKeyState.cpp.
     38
     39        * WebCore.exp: Added findEventWithKeyState, used by WebKit.
     40
    1412006-12-04  Kevin McCullough  <KMcCullough@apple.com>
    242
  • trunk/WebCore/WebCore.exp

    r17984 r18012  
    222222__ZN7WebCore19SelectionController9selectAllEv
    223223__ZN7WebCore21PlatformKeyboardEventC1EP7NSEventb
     224__ZN7WebCore21findEventWithKeyStateEPNS_5EventE
    224225__ZN7WebCore21isBackForwardLoadTypeENS_13FrameLoadTypeE
    225226__ZN7WebCore26NetscapePlugInStreamLoader6createEPNS_5FrameEP11objc_object
  • trunk/WebCore/WebCore.vcproj/WebCore/WebCore.vcproj

    r18000 r18012  
    42164216                        </File>
    42174217                        <File
     4218                                RelativePath="..\..\dom\UIEventWithKeyState.cpp"
     4219                                >
     4220                        </File>
     4221                        <File
    42184222                                RelativePath="..\..\dom\UIEventWithKeyState.h"
    42194223                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r18005 r18012  
    14231423                93309EA3099EB78C0056E581 /* SharedTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 93309EA0099EB78C0056E581 /* SharedTimer.h */; };
    14241424                93309EA4099EB78C0056E581 /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93309EA1099EB78C0056E581 /* Timer.cpp */; };
     1425                93354A3C0B24F8C9003F6DEA /* UIEventWithKeyState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93354A3B0B24F8C9003F6DEA /* UIEventWithKeyState.cpp */; };
    14251426                934706AB0AACD809002C1D43 /* TextDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 932CA7420AAA198E00AD1FAD /* TextDecoder.h */; };
    14261427                9352071909BD3BA500F2038D /* StaticConstructors.h in Headers */ = {isa = PBXBuildFile; fileRef = 9352071709BD3BA500F2038D /* StaticConstructors.h */; };
     
    43994400                93309EA0099EB78C0056E581 /* SharedTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedTimer.h; sourceTree = "<group>"; };
    44004401                93309EA1099EB78C0056E581 /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Timer.cpp; sourceTree = "<group>"; };
     4402                93354A3B0B24F8C9003F6DEA /* UIEventWithKeyState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIEventWithKeyState.cpp; sourceTree = "<group>"; };
    44014403                9352071709BD3BA500F2038D /* StaticConstructors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticConstructors.h; sourceTree = "<group>"; };
    44024404                9352071809BD3BA500F2038D /* TextBoundaries.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextBoundaries.h; sourceTree = "<group>"; };
     
    93619363                                85031B370A44EFC700F992E0 /* UIEvent.cpp */,
    93629364                                85031B380A44EFC700F992E0 /* UIEvent.h */,
     9365                                93354A3B0B24F8C9003F6DEA /* UIEventWithKeyState.cpp */,
    93639366                                85031B390A44EFC700F992E0 /* UIEventWithKeyState.h */,
    93649367                                141B94EE09EC425A000E9413 /* UIEvent.idl */,
     
    1212412127                                B277B4040B22F37C0004BEC6 /* GraphicsContextMac.mm in Sources */,
    1212512128                                ED501DC60B249F2900AE18D9 /* EditorMac.mm in Sources */,
     12129                                93354A3C0B24F8C9003F6DEA /* UIEventWithKeyState.cpp in Sources */,
    1212612130                        );
    1212712131                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/WebCoreSources.bkl

    r17743 r18012  
    530530        dom/TreeWalker.cpp
    531531        dom/UIEvent.cpp
     532        dom/UIEventWithKeyState.cpp
    532533        dom/WheelEvent.cpp
    533534        dom/XMLTokenizer.cpp
  • trunk/WebCore/dom/EventTargetNode.cpp

    r17976 r18012  
    386386{
    387387    assert(!eventDispatchForbidden());
     388
     389    bool ctrlKey = false;
     390    bool altKey = false;
     391    bool shiftKey = false;
     392    bool metaKey = false;
     393    if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {
     394        ctrlKey = keyStateEvent->ctrlKey();
     395        altKey = keyStateEvent->altKey();
     396        shiftKey = keyStateEvent->shiftKey();
     397        metaKey = keyStateEvent->metaKey();
     398    }
     399
    388400    // Like Gecko, we just pass 0 for everything when we make a fake mouse event.
    389401    // Internet Explorer instead gives the current mouse position and state.
    390402    dispatchMouseEvent(eventType, 0, 0, 0, 0, 0, 0,
    391         false, false, false, false, true, 0, underlyingEvent);
     403        ctrlKey, altKey, shiftKey, metaKey, true, 0, underlyingEvent);
    392404}
    393405
  • trunk/WebCore/dom/UIEventWithKeyState.h

    r17597 r18012  
    6464    };
    6565
     66    UIEventWithKeyState* findEventWithKeyState(Event*);
     67
    6668} // namespace WebCore
    6769
  • trunk/WebCore/html/HTMLAnchorElement.cpp

    r17976 r18012  
    181181                return;
    182182            }
    183             if (k->keyEvent()) {
    184                 evt->setDefaultHandled();
    185                 dispatchSimulatedClick(0);
    186                 return;
    187             }
     183            evt->setDefaultHandled();
     184            dispatchSimulatedClick(evt);
     185            return;
    188186        }
    189187
  • trunk/WebKit/ChangeLog

    r18010 r18012  
     12006-12-04  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Adele.
     4
     5        * WebCoreSupport/WebFrameLoaderClient.mm:
     6        (WebFrameLoaderClient::actionDictionary): Changed to use the new
     7        findEventWithKeyState function in WebCore instead of a local function
     8        in this file.
     9
    1102006-12-04  Geoffrey Garen  <ggaren@apple.com>
    211
  • trunk/WebKit/WebCoreSupport/WebFrameLoaderClient.mm

    r17976 r18012  
    11711171}
    11721172
    1173 static const UIEventWithKeyState* findKeyStateEvent(const Event* event)
    1174 {
    1175     for (const Event* e = event; e; e = e->underlyingEvent())
    1176         if (e->isMouseEvent() || e->isKeyboardEvent())
    1177             return static_cast<const UIEventWithKeyState*>(e);
    1178     return 0;
    1179 }
    1180 
    11811173static const MouseEvent* findMouseEvent(const Event* event)
    11821174{
     
    11911183    unsigned modifierFlags = 0;
    11921184    const Event* event = action.event();
    1193     if (const UIEventWithKeyState* keyStateEvent = findKeyStateEvent(event)) {
     1185    if (const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(event))) {
    11941186        if (keyStateEvent->ctrlKey())
    11951187            modifierFlags |= NSControlKeyMask;
Note: See TracChangeset for help on using the changeset viewer.