Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: chrome/browser/renderer_host/render_widget_host.cc

Issue 40065: RenderWidgetHost now stores both the WebKeyboardEvent and the native (Closed)
Patch Set: Redesign Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/renderer_host/render_widget_host.h" 5 #include "chrome/browser/renderer_host/render_widget_host.h"
6 6
7 #include "base/gfx/native_widget_types.h" 7 #include "base/gfx/native_widget_types.h"
8 #include "base/histogram.h" 8 #include "base/histogram.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/keyboard_codes.h" 10 #include "base/keyboard_codes.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 284 }
285 285
286 ForwardInputEvent(mouse_event, sizeof(WebMouseEvent)); 286 ForwardInputEvent(mouse_event, sizeof(WebMouseEvent));
287 } 287 }
288 288
289 void RenderWidgetHost::ForwardWheelEvent( 289 void RenderWidgetHost::ForwardWheelEvent(
290 const WebMouseWheelEvent& wheel_event) { 290 const WebMouseWheelEvent& wheel_event) {
291 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent)); 291 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent));
292 } 292 }
293 293
294 void RenderWidgetHost::ForwardKeyboardEvent(const WebKeyboardEvent& key_event) { 294 void RenderWidgetHost::ForwardKeyboardEvent(
295 const NativeWebKeyboardEvent& key_event) {
295 if (key_event.type == WebKeyboardEvent::CHAR && 296 if (key_event.type == WebKeyboardEvent::CHAR &&
296 (key_event.windows_key_code == base::VKEY_RETURN || 297 (key_event.windows_key_code == base::VKEY_RETURN ||
297 key_event.windows_key_code == base::VKEY_SPACE)) { 298 key_event.windows_key_code == base::VKEY_SPACE)) {
298 OnEnterOrSpace(); 299 OnEnterOrSpace();
299 } 300 }
300 301
302 if (WebInputEvent::IsKeyboardEventType(key_event.type)) {
darin (slow to review) 2009/03/06 04:45:35 previously, we would have only added to the queue
Elliot Glaysher 2009/03/06 20:51:25 Done.
303 // Put all WebKeyboardEvent objects in a queue since we can't trust the
304 // renderer and we need to give something to the UnhandledInputEvent
305 // handler.
306 key_queue_.push(key_event);
307 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size());
308 }
309
310 // Only forward the non-native portions of our event.
301 ForwardInputEvent(key_event, sizeof(WebKeyboardEvent)); 311 ForwardInputEvent(key_event, sizeof(WebKeyboardEvent));
302 } 312 }
303 313
304 void RenderWidgetHost::ForwardInputEvent(const WebInputEvent& input_event, 314 void RenderWidgetHost::ForwardInputEvent(const WebInputEvent& input_event,
305 int event_size) { 315 int event_size) {
306 if (!process_->channel()) 316 if (!process_->channel())
307 return; 317 return;
308 318
309 if (WebInputEvent::IsKeyboardEventType(input_event.type)) {
310 // Put all WebKeyboardEvent objects in a queue since we can't trust the
311 // renderer and we need to give something to the UnhandledInputEvent
312 // handler.
313 key_queue_.push(static_cast<const WebKeyboardEvent&>(input_event));
314 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size());
315 }
316
317 IPC::Message* message = new ViewMsg_HandleInputEvent(routing_id_); 319 IPC::Message* message = new ViewMsg_HandleInputEvent(routing_id_);
318 message->WriteData( 320 message->WriteData(
319 reinterpret_cast<const char*>(&input_event), event_size); 321 reinterpret_cast<const char*>(&input_event), event_size);
320 input_event_start_time_ = TimeTicks::Now(); 322 input_event_start_time_ = TimeTicks::Now();
321 Send(message); 323 Send(message);
322 324
323 // Any input event cancels a pending mouse move event. 325 // Any input event cancels a pending mouse move event.
324 next_mouse_move_.reset(); 326 next_mouse_move_.reset();
325 327
326 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); 328 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs));
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 ForwardMouseEvent(*next_mouse_move_); 564 ForwardMouseEvent(*next_mouse_move_);
563 } 565 }
564 } 566 }
565 567
566 if (WebInputEvent::IsKeyboardEventType(type)) { 568 if (WebInputEvent::IsKeyboardEventType(type)) {
567 if (key_queue_.size() == 0) { 569 if (key_queue_.size() == 0) {
568 LOG(ERROR) << "Got a KeyEvent back from the renderer but we " 570 LOG(ERROR) << "Got a KeyEvent back from the renderer but we "
569 << "don't seem to have sent it to the renderer!"; 571 << "don't seem to have sent it to the renderer!";
570 } else if (key_queue_.front().type != type) { 572 } else if (key_queue_.front().type != type) {
571 LOG(ERROR) << "We seem to have a different key type sent from " 573 LOG(ERROR) << "We seem to have a different key type sent from "
572 << "the renderer. Ignoring event."; 574 << "the renderer. (" << key_queue_.front().type << " vs. "
575 << type << "). Ignoring event.";
573 } else { 576 } else {
574 bool processed = false; 577 bool processed = false;
575 r = message.ReadBool(&iter, &processed); 578 r = message.ReadBool(&iter, &processed);
576 DCHECK(r); 579 DCHECK(r);
577 580
578 KeyQueue::value_type front_item = key_queue_.front(); 581 KeyQueue::value_type front_item = key_queue_.front();
579 key_queue_.pop(); 582 key_queue_.pop();
580 583
581 if (!processed) { 584 if (!processed) {
582 UnhandledKeyboardEvent(front_item); 585 UnhandledKeyboardEvent(front_item);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 657
655 // TODO(darin): do we need to do something else if our backing store is not 658 // TODO(darin): do we need to do something else if our backing store is not
656 // the same size as the advertised view? maybe we just assume there is a 659 // the same size as the advertised view? maybe we just assume there is a
657 // full paint on its way? 660 // full paint on its way?
658 BackingStore* backing_store = BackingStoreManager::Lookup(this); 661 BackingStore* backing_store = BackingStoreManager::Lookup(this);
659 if (!backing_store || (backing_store->size() != view_size)) 662 if (!backing_store || (backing_store->size() != view_size))
660 return; 663 return;
661 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, 664 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect,
662 dx, dy, clip_rect, view_size); 665 dx, dy, clip_rect, view_size);
663 } 666 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698