Created attachment 346676 [details] 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.
<rdar://problem/43013703>
Created attachment 346801 [details] WIP
Created attachment 346813 [details] Fixes the bug
Comment on attachment 346813 [details] Fixes the bug View in context: https://bugs.webkit.org/attachment.cgi?id=346813&action=review > LayoutTests/ChangeLog:8 > + Added a regression test. Due to the lack of adaquete support of textInputController in WebKitTestRunner, Nit - adequate
Comment on attachment 346813 [details] Fixes the bug View in context: https://bugs.webkit.org/attachment.cgi?id=346813&action=review > Source/WebCore/dom/Event.h:122 > + bool ignoreDefaultEventHandler() const { return m_ignoreDefaultEventHandler; } I almost feel like the getter should bed name "isIgnoringDefaultEventHandler", and the method that sets this bit should be called "ignoreDefaultEventHandler", but "ignoreDefaultEventHandler" and "setIgnoreDefaultEventHandler" seem to match "defaultHandled" and "setDefaultHandled" already, so this is probably fine.
(In reply to Wenson Hsieh from comment #5) > Comment on attachment 346813 [details] > Fixes the bug > > View in context: > https://bugs.webkit.org/attachment.cgi?id=346813&action=review > > > Source/WebCore/dom/Event.h:122 > > + bool ignoreDefaultEventHandler() const { return m_ignoreDefaultEventHandler; } > > I almost feel like the getter should bed name > "isIgnoringDefaultEventHandler", and the method that sets this bit should be > called "ignoreDefaultEventHandler", but "ignoreDefaultEventHandler" and > "setIgnoreDefaultEventHandler" seem to match "defaultHandled" and > "setDefaultHandled" already, so this is probably fine. Hm... maybe isDefaultEventHandlerIgnored and setIsDefaultEventHandlerIgnored?
(In reply to Ryosuke Niwa from comment #6) > (In reply to Wenson Hsieh from comment #5) > > Comment on attachment 346813 [details] > > Fixes the bug > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=346813&action=review > > > > > Source/WebCore/dom/Event.h:122 > > > + bool ignoreDefaultEventHandler() const { return m_ignoreDefaultEventHandler; } > > > > I almost feel like the getter should bed name > > "isIgnoringDefaultEventHandler", and the method that sets this bit should be > > called "ignoreDefaultEventHandler", but "ignoreDefaultEventHandler" and > > "setIgnoreDefaultEventHandler" seem to match "defaultHandled" and > > "setDefaultHandled" already, so this is probably fine. > > Hm... maybe isDefaultEventHandlerIgnored and setIsDefaultEventHandlerIgnored? Sounds good to me.
Committed r234718: <https://trac.webkit.org/changeset/234718>