Changeset 252976 in webkit
- Timestamp:
- Dec 1, 2019 7:19:14 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r252965 r252976 1 2019-12-01 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 [Win] Retrieve all following WM_CHAR events at the beginning of processing WM_KEYDOWN event 4 https://bugs.webkit.org/show_bug.cgi?id=204694 5 6 Reviewed by Ross Kirsling. 7 8 In Windows ports, WM_KEYDOWN dispatches keydown event, and 9 WM_CHAR dispatches keypress event. If a keydown event is canceled 10 by calling preventDefault, the following corresponding keypress 11 events shouldn't be dispatched. 12 13 WebKit1 implemented it by removing WM_CHAR events if the keydown 14 event is consumed. However, WebKit2 can't do so because WebKit2 15 processes key events asynchronously. Thus, retrieve all following 16 WM_CHAR events, and dispatch them after processing the keydown 17 and if it is not consumed. 18 19 In addition to that, retrieving following WM_CHAR events is needed 20 to fix Bug 204672 because the events are needed for 'key' property 21 of keydown KeyboardEvent for dead key combination. 22 23 Gecko and Chromium also implements 'key' property in the same approach. 24 25 Test: Covered by existing fast/events/inputText-never-fired-on-keydown-cancel.html and fast/events/keydown-keypress-preventDefault.html 26 27 * Shared/NativeWebKeyboardEvent.h: Added m_pendingCharEvents as Vector<MSG>. 28 (WebKit::NativeWebKeyboardEvent::pendingCharEvents const): 29 * Shared/win/NativeWebKeyboardEventWin.cpp: 30 (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent): 31 * UIProcess/WebPageProxy.cpp: 32 (WebKit::WebPageProxy::didReceiveEvent): 33 * UIProcess/WebPageProxy.h: 34 * UIProcess/win/WebPageProxyWin.cpp: 35 (WebKit::WebPageProxy::dispatchPendingCharEvents): 36 * UIProcess/win/WebView.cpp: 37 (WebKit::WebView::onKeyEvent): 38 1 39 2019-11-30 Tim Horton <timothy_horton@apple.com> 2 40 -
trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h
r251650 r252976 77 77 NativeWebKeyboardEvent(struct wpe_input_keyboard_event*); 78 78 #elif PLATFORM(WIN) 79 NativeWebKeyboardEvent(HWND, UINT message, WPARAM, LPARAM );79 NativeWebKeyboardEvent(HWND, UINT message, WPARAM, LPARAM, Vector<MSG>&& pendingCharEvents); 80 80 #endif 81 81 … … 91 91 #elif PLATFORM(WIN) 92 92 const MSG* nativeEvent() const { return &m_nativeEvent; } 93 const Vector<MSG>& pendingCharEvents() const { return m_pendingCharEvents; } 93 94 #else 94 95 const void* nativeEvent() const { return nullptr; } … … 107 108 #elif PLATFORM(WIN) 108 109 MSG m_nativeEvent; 110 Vector<MSG> m_pendingCharEvents; 109 111 #endif 110 112 }; -
trunk/Source/WebKit/Shared/win/NativeWebKeyboardEventWin.cpp
r239550 r252976 34 34 using namespace WebCore; 35 35 36 NativeWebKeyboardEvent::NativeWebKeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )36 NativeWebKeyboardEvent::NativeWebKeyboardEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, Vector<MSG>&& pendingCharEvents) 37 37 : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(hwnd, message, wParam, lParam)) 38 38 , m_nativeEvent(createNativeEvent(hwnd, message, wParam, lParam)) 39 , m_pendingCharEvents(WTFMove(pendingCharEvents)) 39 40 { 40 41 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r252692 r252976 6576 6576 MESSAGE_CHECK(m_process, type == event.type()); 6577 6577 6578 #if PLATFORM(WIN) 6579 if (!handled && type == WebEvent::RawKeyDown) 6580 dispatchPendingCharEvents(event); 6581 #endif 6582 6578 6583 bool canProcessMoreKeyEvents = !m_keyEventQueue.isEmpty(); 6579 6584 if (canProcessMoreKeyEvents) { -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r252692 r252976 866 866 bool isProcessingKeyboardEvents() const; 867 867 void handleKeyboardEvent(const NativeWebKeyboardEvent&); 868 #if PLATFORM(WIN) 869 void dispatchPendingCharEvents(const NativeWebKeyboardEvent&); 870 #endif 868 871 869 872 #if ENABLE(MAC_GESTURE_EVENTS) -
trunk/Source/WebKit/UIProcess/win/WebPageProxyWin.cpp
r249335 r252976 28 28 #include "WebPageProxy.h" 29 29 30 #include "NativeWebKeyboardEvent.h" 30 31 #include "PageClientImpl.h" 31 32 #include <WebCore/SearchPopupMenuDB.h> … … 87 88 #endif 88 89 90 void WebPageProxy::dispatchPendingCharEvents(const NativeWebKeyboardEvent& keydownEvent) 91 { 92 auto& pendingCharEvents = keydownEvent.pendingCharEvents(); 93 for (auto it = pendingCharEvents.rbegin(); it != pendingCharEvents.rend(); it++) 94 m_keyEventQueue.prepend(NativeWebKeyboardEvent(it->hwnd, it->message, it->wParam, it->lParam, { })); 95 } 89 96 90 97 } // namespace WebKit -
trunk/Source/WebKit/UIProcess/win/WebView.cpp
r250534 r252976 468 468 LRESULT WebView::onKeyEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled) 469 469 { 470 m_page->handleKeyboardEvent(NativeWebKeyboardEvent(hWnd, message, wParam, lParam)); 470 Vector<MSG> pendingCharEvents; 471 if (message == WM_KEYDOWN) { 472 MSG msg; 473 // WM_SYSCHAR events should not be removed, because WebKit is using WM_SYSCHAR for access keys and they can't be canceled. 474 while (PeekMessage(&msg, hWnd, WM_CHAR, WM_DEADCHAR, PM_REMOVE)) { 475 if (msg.message == WM_CHAR) 476 pendingCharEvents.append(msg); 477 } 478 } 479 m_page->handleKeyboardEvent(NativeWebKeyboardEvent(hWnd, message, wParam, lParam, WTFMove(pendingCharEvents))); 471 480 472 481 // We claim here to always have handled the event. If the event is not in fact handled, we will -
trunk/Source/WebKitLegacy/win/ChangeLog
r252973 r252976 1 2019-12-01 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 [Win] Retrieve all following WM_CHAR events at the beginning of processing WM_KEYDOWN event 4 https://bugs.webkit.org/show_bug.cgi?id=204694 5 6 Reviewed by Ross Kirsling. 7 8 * WebView.cpp: 9 (WebView::keyDown): Added a variable pendingCharEvents of 10 Vector<MSG> to preserve following WM_CHAR events. Dispatch them if 11 the WM_KEYDOWN isn't consumed. 12 1 13 2019-12-01 Fujii Hironori <Hironori.Fujii@sony.com> 2 14 -
trunk/Source/WebKitLegacy/win/WebView.cpp
r252965 r252976 2377 2377 Frame& frame = m_page->focusController().focusedOrMainFrame(); 2378 2378 2379 Vector<MSG> pendingCharEvents; 2380 MSG msg; 2381 while (PeekMessage(&msg, m_viewWindow, WM_CHAR, WM_DEADCHAR, PM_REMOVE)) { 2382 // FIXME: remove WM_UNICHAR, too 2383 // WM_SYSCHAR events should not be removed, because WebKit is using WM_SYSCHAR for access keys and they can't be canceled. 2384 if (msg.message == WM_CHAR) 2385 pendingCharEvents.append(msg); 2386 } 2387 2379 2388 PlatformKeyboardEvent keyEvent(m_viewWindow, virtualKeyCode, keyData, PlatformEvent::RawKeyDown, systemKeyDown); 2380 2389 bool handled = frame.eventHandler().keyEvent(keyEvent); … … 2385 2394 return false; 2386 2395 2387 if (handled) { 2388 // FIXME: remove WM_UNICHAR, too 2389 MSG msg; 2390 // WM_SYSCHAR events should not be removed, because access keys are implemented in WebCore in WM_SYSCHAR handler. 2391 if (!systemKeyDown) 2392 ::PeekMessage(&msg, m_viewWindow, WM_CHAR, WM_CHAR, PM_REMOVE); 2396 if (handled) 2393 2397 return true; 2394 }2395 2398 2396 2399 // We need to handle back/forward using either Ctrl+Left/Right Arrow keys. … … 2403 2406 2404 2407 // Need to scroll the page if the arrow keys, pgup/dn, or home/end are hit. 2405 ScrollDirection direction; 2406 ScrollGranularity granularity; 2408 bool willScroll = true; 2409 ScrollDirection direction { }; 2410 ScrollGranularity granularity { }; 2407 2411 switch (virtualKeyCode) { 2408 2412 case VK_LEFT: … … 2439 2443 break; 2440 2444 default: 2441 return false; 2442 } 2443 2444 return frame.eventHandler().scrollRecursively(direction, granularity); 2445 willScroll = false; 2446 break; 2447 } 2448 2449 if (willScroll) { 2450 handled = frame.eventHandler().scrollRecursively(direction, granularity); 2451 if (handled) 2452 return true; 2453 } 2454 2455 for (auto& msg : pendingCharEvents) 2456 DispatchMessage(&msg); 2457 return false; 2445 2458 } 2446 2459
Note: See TracChangeset
for help on using the changeset viewer.