Skip to content

Commit 030740e

Browse files
authored
Merge pull request #1376 from asurdej-comcast/key_throttle
[KeyEvent] Throttle keys repetition
2 parents 59d63a5 + 2751cb6 commit 030740e

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

Source/WebKit/Shared/WebKeyboardEvent.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,18 @@ bool WebKeyboardEvent::isKeyboardEventType(Type type)
223223
return type == RawKeyDown || type == KeyDown || type == KeyUp || type == Char;
224224
}
225225

226+
bool operator==(const WebKeyboardEvent& a, const WebKeyboardEvent& b)
227+
{
228+
return a.type() == b.type()
229+
&& a.modifiers() == b.modifiers()
230+
&& a.text() == b.text()
231+
&& a.unmodifiedText() == b.unmodifiedText()
232+
&& a.key() == b.key()
233+
&& a.code() == b.code()
234+
&& a.keyIdentifier() == b.keyIdentifier()
235+
&& a.windowsVirtualKeyCode() == b.windowsVirtualKeyCode()
236+
&& a.nativeVirtualKeyCode() == b.nativeVirtualKeyCode()
237+
&& a.macCharCode() == b.macCharCode();
238+
}
239+
226240
} // namespace WebKit

Source/WebKit/Shared/WebKeyboardEvent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class WebKeyboardEvent : public WebEvent {
8282

8383
static bool isKeyboardEventType(Type);
8484

85+
friend bool operator==(const WebKeyboardEvent&, const WebKeyboardEvent&);
8586
private:
8687
String m_text;
8788
String m_unmodifiedText;

Source/WebKit/UIProcess/WebPageProxy.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,6 +3111,11 @@ bool WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
31113111

31123112
LOG(KeyHandling, "WebPageProxy::handleKeyboardEvent: %s", webKeyboardEventTypeString(event.type()));
31133113

3114+
if (event.type() == WebEvent::KeyDown && !m_keyEventQueue.isEmpty() && m_keyEventQueue.last() == event) {
3115+
// Throtthe key repetition if we still have previous keypress pending
3116+
return true;
3117+
}
3118+
31143119
m_keyEventQueue.append(event);
31153120

31163121
m_process->startResponsivenessTimer(event.type() == WebEvent::KeyDown ? WebProcessProxy::UseLazyStop::Yes : WebProcessProxy::UseLazyStop::No);

0 commit comments

Comments
 (0)