[Webkit-unassigned] [Bug 188370] New: Events handled by input method invoke default event handler[regression]

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Aug 6 19:36:32 PDT 2018


https://bugs.webkit.org/show_bug.cgi?id=188370

            Bug ID: 188370
           Summary: Events handled by input method invoke default event
                    handler[regression]
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Macintosh
                OS: macOS 10.13
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebCore JavaScript
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: mzpppp at gmail.com

Created attachment 346676

  --> https://bugs.webkit.org/attachment.cgi?id=346676&action=review

Problem

When tab key pressed on text box, focus always move to next element in spite of input method behavior. IMO, this is regression bug.

# Environments
 [affected]
 - Movaje + Safari 12.0 (14606.1.30)
 - High Sierra + Safari 12.0 (14606.1.30)
 - High Sierra + WebKit trunk(r234578)

 [not affected]
 - High Sierra + Safari 11.1.2 (13605.3.8)

# Reproduce steps

 1. Open web page containing text fields (e.g. https://twitter.com).
 2. Enable input methods (e.g. Apple Japanese Input Method.)
 3. Type A, and 'あ' is inserted.
 4. Press tab.

# Except behavior
Tab key event is consumed by IM, and focus doesn't move.

# Actual behavior
Tab key event is consumed by IM, and focus moves to next element.

# Details
Reproduce steps is common case. The real problem exists between input method consumed events and default event handler.
Safari 11 doesn't invoke default event handler by IM handled event. But, Safari12/WebKit trunk invokes default event handler by IM handled event

This regression is introduced by https://trac.webkit.org/changeset/228260/webkit. Especially by change of WebCore/dom/EventDispacher.cpp.

An event handled by input method is marked as default handled at 

    // WebCore/page/EventHandler.cpp
    // EventHandler::internalKeyEvent(const PlatformKeyboardEvent& initialKeyEvent)
    if (handledByInputMethod) {
        keyDownEvent.setWindowsVirtualKeyCode(CompositionEventKeyCode);
        keydown = KeyboardEvent::create(keyDownEvent, &m_frame.windowProxy());
        keydown->setTarget(element);
        keydown->setDefaultHandled();
    }

Before the changes, event dispatcher ignores these event.

    // WebCore/dom/EventDispatcher.cpp
    // EventDispatcher::dispatchEvent(Node& node, Event& event)
    if (!event.defaultPrevented() && !event.defaultHandled()) {
        // FIXME: Not clear why we need to reset the target for the default event handlers.
        // We should research this, and remove this code if possible.
        auto* finalTarget = event.target();
        event.setTarget(EventPath::eventTargetRespectingTargetRules(node));
        callDefaultEventHandlersInBubblingOrder(event, eventPath);
        event.setTarget(finalTarget);
    }

However, the change inserted `event.resetBeforeDispatch()`. This method resets defaultHandled field.

    // WebCore/dom/EventDispatcher.cpp
    // EventDispatcher::dispatchEvent(Node& node, Event& event)

    event.resetBeforeDispatch();
    // ....
    if (!event.defaultPrevented() && !event.defaultHandled()) {
        // FIXME: Not clear why we need to reset the target for the default event handlers.
        // We should research this, and remove this code if possible.
        auto* finalTarget = event.target();
        event.setTarget(EventPath::eventTargetRespectingTargetRules(node));
        callDefaultEventHandlersInBubblingOrder(event, eventPath);
        event.setTarget(finalTarget);
    }

This is why events handled by input method invoke default event handler.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180807/2ee6c273/attachment.html>


More information about the webkit-unassigned mailing list