Embed keyboard shortcut bit in WebKeyboardEvent
Before a WebKeyboardEvent is forwarded to the renderer, the content
embedder can tag it as a keyboard shortcut. This shortcut bit is passed
along with the input event to the renderer, allowing the renderer to
suppress follow-up Char events for unhandled RawKeyDown events that are
part of a keyboard shortcut.
However, passing around this keyboard shortcut bit separately is awkward
and pollutes a number of input-related methods. Instead, just embed the
shortcut bit directly in the WebKeyboardEvent.
BUG=302492
Review URL: https://codereview.chromium.org/1391843006
Cr-Commit-Position: refs/heads/master@{#354384}
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 1d4293da..2a9ad59d 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -1045,8 +1045,7 @@
}
void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
- const ui::LatencyInfo& latency_info,
- bool is_keyboard_shortcut) {
+ const ui::LatencyInfo& latency_info) {
if (!input_event)
return;
base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_,
@@ -1158,6 +1157,9 @@
// If this RawKeyDown event corresponds to a browser keyboard shortcut and
// it's not processed by webkit, then we need to suppress the upcoming Char
// events.
+ bool is_keyboard_shortcut =
+ input_event->type == WebInputEvent::RawKeyDown &&
+ static_cast<const WebKeyboardEvent*>(input_event)->isBrowserShortcut;
if (!processed && is_keyboard_shortcut)
suppress_next_char_events_ = true;