Commit b68a0e50 authored by apavlov@chromium.org's avatar apavlov@chromium.org

Revert r112160 ("Send one WebKeyboardEvent to the RenderWidget at a time.")

This change has resulted in severe regressions in keyboard event dispatching -
the keydown and keypress events are no longer dispatched synchronously. Reverting as suggested by Darin Fisher.

BUG=106224
TEST=manual
TBR=darin


Review URL: http://codereview.chromium.org/8885009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113603 0039d316-1c4b-4281-b951-d872f2087c98
parent 5ca4959f
...@@ -283,7 +283,6 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, ...@@ -283,7 +283,6 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener,
void ForwardWheelEvent(const WebKit::WebMouseWheelEvent& wheel_event); void ForwardWheelEvent(const WebKit::WebMouseWheelEvent& wheel_event);
void ForwardGestureEvent(const WebKit::WebGestureEvent& gesture_event); void ForwardGestureEvent(const WebKit::WebGestureEvent& gesture_event);
virtual void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event); virtual void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event);
virtual void ForwardNextKeyboardEvent();
virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event); virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event);
...@@ -459,7 +458,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, ...@@ -459,7 +458,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener,
protected: protected:
// Internal implementation of the public Forward*Event() methods. // Internal implementation of the public Forward*Event() methods.
void ForwardInputEvent(const WebKit::WebInputEvent& input_event, void ForwardInputEvent(const WebKit::WebInputEvent& input_event,
int event_size); int event_size, bool is_keyboard_shortcut);
// Called when we receive a notification indicating that the renderer // Called when we receive a notification indicating that the renderer
// process has gone. This will reset our state so that our state will be // process has gone. This will reset our state so that our state will be
...@@ -760,14 +759,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, ...@@ -760,14 +759,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener,
base::TimeTicks repaint_start_time_; base::TimeTicks repaint_start_time_;
// Queue of keyboard events that we need to track. // Queue of keyboard events that we need to track.
struct Key { typedef std::deque<NativeWebKeyboardEvent> KeyQueue;
Key(const NativeWebKeyboardEvent& event, bool is_shortcut)
: event(event), is_shortcut(is_shortcut) {
}
NativeWebKeyboardEvent event;
bool is_shortcut;
};
typedef std::deque<Key> KeyQueue;
// A queue of keyboard events. We can't trust data from the renderer so we // A queue of keyboard events. We can't trust data from the renderer so we
// stuff key events into a queue and pop them out on ACK, feeding our copy // stuff key events into a queue and pop them out on ACK, feeding our copy
...@@ -787,27 +779,19 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, ...@@ -787,27 +779,19 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener,
bool text_direction_canceled_; bool text_direction_canceled_;
// Indicates if the next sequence of Char events should be suppressed or not. // Indicates if the next sequence of Char events should be suppressed or not.
// // System may translate a RawKeyDown event into zero or more Char events,
// The system may translate a RawKeyDown event into zero or more Char events,
// usually we send them to the renderer directly in sequence. However, If a // usually we send them to the renderer directly in sequence. However, If a
// RawKeyDown event was not handled by the renderer but was handled by our // RawKeyDown event was not handled by the renderer but was handled by
// UnhandledKeyboardEvent() method, e.g. as an accelerator key, then we shall // our UnhandledKeyboardEvent() method, e.g. as an accelerator key, then we
// not send the following sequence of Char events, which was generated by // shall not send the following sequence of Char events, which was generated
// this RawKeyDown event, to the renderer. Otherwise the renderer may handle // by this RawKeyDown event, to the renderer. Otherwise the renderer may
// the Char events and cause unexpected behavior. For example, pressing // handle the Char events and cause unexpected behavior.
// alt-2 may let the browser switch to the second tab, but the Char event // For example, pressing alt-2 may let the browser switch to the second tab,
// generated by alt-2 may also activate a HTML element if its accesskey // but the Char event generated by alt-2 may also activate a HTML element
// happens to be "2", then the user may get confused when switching back to // if its accesskey happens to be "2", then the user may get confused when
// the original tab, because the content may already be changed. // switching back to the original tab, because the content may already be
// // changed.
// If true, suppress_incoming_char_events_ prevents Char events from being bool suppress_next_char_events_;
// added to key_queue_.
//
// If true, suppress_outgoing_char_events_ prevents Char events from being
// removed from key_queue_ and forwarded to the renderer.
//
bool suppress_incoming_char_events_;
bool suppress_outgoing_char_events_;
std::vector<gfx::PluginWindowHandle> deferred_plugin_handles_; std::vector<gfx::PluginWindowHandle> deferred_plugin_handles_;
......
...@@ -747,7 +747,10 @@ IPC_MESSAGE_ROUTED4(ViewMsg_PaintAtSize, ...@@ -747,7 +747,10 @@ IPC_MESSAGE_ROUTED4(ViewMsg_PaintAtSize,
// This signals the render view that it can send another UpdateRect message. // This signals the render view that it can send another UpdateRect message.
IPC_MESSAGE_ROUTED0(ViewMsg_UpdateRect_ACK) IPC_MESSAGE_ROUTED0(ViewMsg_UpdateRect_ACK)
// Message payload includes a blob that should be cast to WebInputEvent // Message payload includes:
// 1. A blob that should be cast to WebInputEvent
// 2. An optional boolean value indicating if a RawKeyDown event is associated
// to a keyboard shortcut of the browser.
IPC_MESSAGE_ROUTED0(ViewMsg_HandleInputEvent) IPC_MESSAGE_ROUTED0(ViewMsg_HandleInputEvent)
// This message notifies the renderer that the next key event is bound to one // This message notifies the renderer that the next key event is bound to one
......
...@@ -91,6 +91,7 @@ RenderWidget::RenderWidget(WebKit::WebPopupType popup_type) ...@@ -91,6 +91,7 @@ RenderWidget::RenderWidget(WebKit::WebPopupType popup_type)
can_compose_inline_(true), can_compose_inline_(true),
popup_type_(popup_type), popup_type_(popup_type),
pending_window_rect_count_(0), pending_window_rect_count_(0),
suppress_next_char_events_(false),
is_accelerated_compositing_active_(false), is_accelerated_compositing_active_(false),
animation_update_pending_(false), animation_update_pending_(false),
animation_task_posted_(false), animation_task_posted_(false),
...@@ -445,6 +446,11 @@ void RenderWidget::OnHandleInputEvent(const IPC::Message& message) { ...@@ -445,6 +446,11 @@ void RenderWidget::OnHandleInputEvent(const IPC::Message& message) {
const WebInputEvent* input_event = const WebInputEvent* input_event =
reinterpret_cast<const WebInputEvent*>(data); reinterpret_cast<const WebInputEvent*>(data);
bool is_keyboard_shortcut = false;
// is_keyboard_shortcut flag is only available for RawKeyDown events.
if (input_event->type == WebInputEvent::RawKeyDown)
message.ReadBool(&iter, &is_keyboard_shortcut);
bool prevent_default = false; bool prevent_default = false;
if (WebInputEvent::isMouseEventType(input_event->type)) { if (WebInputEvent::isMouseEventType(input_event->type)) {
prevent_default = WillHandleMouseEvent( prevent_default = WillHandleMouseEvent(
...@@ -452,8 +458,17 @@ void RenderWidget::OnHandleInputEvent(const IPC::Message& message) { ...@@ -452,8 +458,17 @@ void RenderWidget::OnHandleInputEvent(const IPC::Message& message) {
} }
bool processed = prevent_default; bool processed = prevent_default;
if (!processed && webwidget_) if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
processed = webwidget_->handleInputEvent(*input_event); suppress_next_char_events_ = false;
if (!processed && webwidget_)
processed = webwidget_->handleInputEvent(*input_event);
}
// 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.
if (!processed && is_keyboard_shortcut)
suppress_next_char_events_ = true;
IPC::Message* response = IPC::Message* response =
new ViewHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type, new ViewHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type,
......
...@@ -459,6 +459,9 @@ class CONTENT_EXPORT RenderWidget ...@@ -459,6 +459,9 @@ class CONTENT_EXPORT RenderWidget
scoped_ptr<IPC::Message> pending_input_event_ack_; scoped_ptr<IPC::Message> pending_input_event_ack_;
// Indicates if the next sequence of Char events should be suppressed or not.
bool suppress_next_char_events_;
// Set to true if painting to the window is handled by the accelerated // Set to true if painting to the window is handled by the accelerated
// compositor. // compositor.
bool is_accelerated_compositing_active_; bool is_accelerated_compositing_active_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment