Changeset 24542 in webkit


Ignore:
Timestamp:
Jul 23, 2007 2:03:14 PM (17 years ago)
Author:
oliver
Message:

LayoutTests:

Reviewed by Darin.

Added initial pseudo-hangul IM, and tests for behaviour of hangul (<rdar://problem/5352152>)
Updated keydown-keypress-preventDefault to be correct, and to have an demonstrate that keys have been inserted.
Updated kotoeri test to perform more validation and check against updated behaviour

  • editing/input/mac/hangul-enter-confirms-and-sends-keypress-expected.txt: Added.
  • editing/input/mac/hangul-enter-confirms-and-sends-keypress.html: Added.
  • editing/input/mac/hangul.js: Added.
  • editing/input/mac/kotoeri-enter-to-confirm-and-newline.html:
  • fast/events/keydown-keypress-preventDefault-expected.txt:
  • fast/events/keydown-keypress-preventDefault.html:

WebCore:

Reviewed by Darin.


<rdar://problem/5353577> WebKit key event behaviour needs to better match other browsers keyevent behaviour
<rdar://problem/5352152> REGRESSION (24399-24479): Pressing Enter in a search field at apple.com no longer starts a search with Korean IM
<rdar://problem/5352649> WebKit should send keyDown event on autorepeat keyDowns
http://bugs.webkit.org/show_bug.cgi?id=14690

Perform Input Method call first so that our behaviour is determined by whether or not
the input method has actually handle the event, rather than by making guesses based
on the existences of marked text. This fixes issues with IMs that have side effects
even on events they do not handle.

Refactored the code in order to improve clarity given the hoisting required by performing
the IM call earlier.

  • page/EventHandler.cpp: (WebCore::EventHandler::keyEvent):

WebKit:

Reviewed by Darin.

We have to be able to support insertText: followed by doCommandBySelector: in
order to support the 2- and 3-Set Korean and RuSwitcher IMs at least.

  • WebView/WebHTMLView.mm: (-[WebHTMLView insertText:]):
Location:
trunk
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r24541 r24542  
     12007-07-23  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        Added initial pseudo-hangul IM, and tests for behaviour of hangul (<rdar://problem/5352152>)
     6        Updated keydown-keypress-preventDefault to be correct, and to have an demonstrate that keys have been inserted.
     7        Updated kotoeri test to perform more validation and check against updated behaviour
     8
     9        * editing/input/mac/hangul-enter-confirms-and-sends-keypress-expected.txt: Added.
     10        * editing/input/mac/hangul-enter-confirms-and-sends-keypress.html: Added.
     11        * editing/input/mac/hangul.js: Added.
     12        * editing/input/mac/kotoeri-enter-to-confirm-and-newline.html:
     13        * fast/events/keydown-keypress-preventDefault-expected.txt:
     14        * fast/events/keydown-keypress-preventDefault.html:
     15
    1162007-07-23  Anders Carlsson  <andersca@apple.com>
    217
  • trunk/LayoutTests/editing/input/mac/kotoeri-enter-to-confirm-and-newline.html

    r24517 r24542  
    1414<script src="kotoeri.js"></script>
    1515<script>
    16     var shouldUseIECompositionKeyCode = false;
     16    var shouldBeCompositionEvent = false;
    1717    function keyDown() {
    1818        if (!window.layoutTestController) {
     
    2020            return;
    2121        }
    22         if (shouldUseIECompositionKeyCode && event.keyCode != 229)
     22        if (shouldBeCompositionEvent && event.keyCode != 229)
    2323            log("FAILURE: received keyCode " + event.keyCode + " in a keydown when VK_PROCESSKEY is expected");
     24        else if (!shouldBeCompositionEvent && event.keyCode == 229)
     25            log("FAILURE: received a keyDown with VK_PROCESSKEY as the keyCode, when an actual key code was expected.");
    2426        else
    2527            log("Received valid keydown event");
    2628    }
    2729   
    28     var shouldBeCompositionEvent = false;
    2930    function keyPress() {
    3031        if (!window.layoutTestController) {
     
    4546        shouldBeCompositionEvent = true;
    4647        eventSender.keyDown('t');
    47         shouldUseIECompositionKeyCode = true;
    4848        eventSender.keyDown('o');
    4949        eventSender.keyDown('u');
     
    5454        eventSender.keyDown('\n');
    5555        shouldBeCompositionEvent = false;
    56         shouldUseIECompositionKeyCode = false;
    5756        eventSender.keyDown('\n');
    5857        if (targetInput.value != "toukyou")
  • trunk/LayoutTests/fast/events/keydown-keypress-preventDefault-expected.txt

    r24397 r24542  
    1 This tests that preventing the default behavior for a keydown event will not prevent the keypress event from firing, and the text will be inserted.
     1This tests that preventing the default behavior for a keydown event will not prevent the keypress event from firing, but will prevent text from being inserted.
    22This matches IE7 and Firefox.
    33 
     
    1111key press
    1212
     13
  • trunk/LayoutTests/fast/events/keydown-keypress-preventDefault.html

    r24397 r24542  
    66        if (window.layoutTestController) {
    77            layoutTestController.dumpAsText();
    8             eventSender.keyDown('P');
     8            eventSender.keyDown('F');
    99            eventSender.keyDown('A');
    10             eventSender.keyDown('S');
    11             eventSender.keyDown('S');
     10            eventSender.keyDown('I');
     11            eventSender.keyDown('L');
     12            log(tf.value);
    1213        }
    1314    }
     
    1920</script>
    2021<body onload="test()">
    21     This tests that preventing the default behavior for a keydown event will not prevent the keypress event from firing, and the text will be inserted.<br>
     22    This tests that preventing the default behavior for a keydown event will not prevent the keypress event from firing, but will prevent text from being inserted.<br>
    2223    This matches IE7 and Firefox.<br>
    2324    <input id="tf" onkeydown="log('key down'); event.preventDefault();" onkeypress="log('key press')">
  • trunk/WebCore/ChangeLog

    r24541 r24542  
     12007-07-23  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Darin.
     4       
     5        <rdar://problem/5353577> WebKit key event behaviour needs to better match other browsers keyevent behaviour
     6        <rdar://problem/5352152> REGRESSION (24399-24479): Pressing Enter in a search field at apple.com no longer starts a search with Korean IM
     7        <rdar://problem/5352649> WebKit should send keyDown event on autorepeat keyDowns
     8        http://bugs.webkit.org/show_bug.cgi?id=14690
     9
     10        Perform Input Method call first so that our behaviour is determined by whether or not
     11        the input method has actually handle the event, rather than by making guesses based
     12        on the existences of marked text.  This fixes issues with IMs that have side effects
     13        even on events they do not handle.
     14
     15        Refactored the code in order to improve clarity given the hoisting required by performing
     16        the IM call earlier.
     17
     18        * page/EventHandler.cpp:
     19        (WebCore::EventHandler::keyEvent):
     20
    1212007-07-23  Anders Carlsson  <andersca@apple.com>
    222
  • trunk/WebCore/page/EventHandler.cpp

    r24499 r24542  
    13791379bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
    13801380{
    1381    
    1382     PlatformKeyboardEvent keyEvent = initialKeyEvent;
    13831381    // Check for cases where we are too early for events -- possible unmatched key up
    13841382    // from pressing return in the location bar.
     
    13861384    if (!node)
    13871385        return false;
    1388    
    1389     if (!keyEvent.isKeyUp())
    1390         m_frame->loader()->resetMultipleFormSubmissionProtection();
    1391    
    1392     // When performing composition we don't want to send keypress events for autorepeats
    1393     int windowKey = keyEvent.WindowsKeyCode();
    1394     if (m_frame->markedTextRange() && !keyEvent.isKeyUp()) {
    1395         keyEvent.setIsAutoRepeat(false);
    1396         keyEvent.setWindowsKeyCode(CompositionEventKeyCode);
    1397     }
    1398    
    1399     bool result = !node->dispatchKeyEvent(keyEvent);
    1400    
    1401     if (keyEvent.isAutoRepeat() || keyEvent.isKeyUp())
    1402         return result;
     1386       
     1387    if (initialKeyEvent.isKeyUp())
     1388        return !node->dispatchKeyEvent(initialKeyEvent);
     1389       
     1390    m_frame->loader()->resetMultipleFormSubmissionProtection();
     1391   
     1392    // Prepare the keyPress in advance of the keyDown so we can fire the input method
     1393    // in advance of keyDown
     1394    PlatformKeyboardEvent keyPressEvent = initialKeyEvent;   
     1395    keyPressEvent.setIsAutoRepeat(true);
     1396    RefPtr<KeyboardEvent> keypress = new KeyboardEvent(keyPressEvent, m_frame->document()->defaultView());
     1397    keypress->setTarget(node);
     1398   
     1399    // Run input method in advance of DOM event handling.  This may result in the IM
     1400    // modifying the page prior the keydown event, however this behaviour is necessary
     1401    // in order to match IE
     1402    m_frame->editor()->handleInputMethodKeypress(keypress.get());
     1403   
     1404    bool handledByInputMethod = keypress->defaultHandled();
     1405   
     1406    PlatformKeyboardEvent keyDownEvent = initialKeyEvent;
     1407   
     1408    if (handledByInputMethod)
     1409        keyDownEvent.setWindowsKeyCode(CompositionEventKeyCode);
     1410       
     1411    // We always send keyDown and keyPress for all events, including autorepeat keys
     1412    keyDownEvent.setIsAutoRepeat(false);
     1413   
     1414    bool result = !node->dispatchKeyEvent(keyDownEvent);
    14031415   
    14041416    // Focus may have change during the keyDown handling, so refetch node
     
    14071419        return result;
    14081420   
    1409     keyEvent.setWindowsKeyCode(windowKey);
    1410    
    1411     // Create a keypress event from the keydown event
    1412     RefPtr<KeyboardEvent> keypress;
    1413     PlatformKeyboardEvent key = keyEvent;
    1414     key.setIsAutoRepeat(true);
    1415     keypress = new KeyboardEvent(key, m_frame->document()->defaultView());
    1416     keypress->setTarget(node);
    1417    
    1418     m_frame->editor()->handleInputMethodKeypress(keypress.get());
    1419    
    14201421    if (keypress->defaultHandled())
    14211422        return true;
    14221423   
    1423     if (m_frame->markedTextRange())
     1424    if (handledByInputMethod)
    14241425        return result;
    14251426   
     1427    // If the default handling has been prevented on the keydown, we prevent it on
     1428    // the keypress as well
     1429    if (result)
     1430        keypress->setDefaultHandled();
     1431   
    14261432    ExceptionCode ec;
    1427     node->dispatchEvent(keypress, ec, true);
     1433    !node->dispatchEvent(keypress, ec, true);
     1434   
    14281435    return result || keypress->defaultHandled() || keypress->defaultPrevented();
    14291436}
  • trunk/WebKit/ChangeLog

    r24540 r24542  
     12007-07-23  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        We have to be able to support insertText: followed by doCommandBySelector: in
     6        order to support the 2- and 3-Set Korean and RuSwitcher IMs at least.
     7
     8        * WebView/WebHTMLView.mm:
     9        (-[WebHTMLView insertText:]):
     10
    1112007-07-23  Alice Liu  <alice.liu@apple.com>
    212
  • trunk/WebKit/WebView/WebHTMLView.mm

    r24540 r24542  
    54765476- (void)insertText:(id)string
    54775477{
    5478     // Use pointer to get parameters passed to us by the caller of interpretKeyEvents.
    5479     // If insertText: is called by interpretKeyEvents, we assume that's the only thing it will do;
    5480     // we don't handle multiple calls to this the way we do in doCommandBySelector:, and we also
    5481     // don't handle a mix of doCommandBySelector: and insertText:.
    54825478    WebHTMLViewInterpretKeyEventsParameters* parameters = _private->interpretKeyEventsParameters;
    54835479    _private->interpretKeyEventsParameters = 0;
     
    55255521        eventHandled = coreFrame && coreFrame->editor()->insertText(eventText, event);
    55265522    }
    5527 
    5528     if (parameters)
    5529         parameters->eventWasHandled = eventHandled;
     5523   
     5524    if (!parameters)
     5525        return;
     5526   
     5527    if (isFromInputMethod) {
     5528        // Allow doCommandBySelector: to be called after insertText: by resetting interpretKeyEventsParameters
     5529        _private->interpretKeyEventsParameters = parameters;
     5530        parameters->consumedByIM = YES;
     5531        return;
     5532    }
     5533   
     5534    parameters->eventWasHandled = eventHandled;
    55305535}
    55315536
Note: See TracChangeset for help on using the changeset viewer.