Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/message_loop.h" | 9 #include "base/message_loop.h" |
| 9 #include "base/keyboard_codes.h" | 10 #include "base/keyboard_codes.h" |
| 10 #include "chrome/browser/renderer_host/backing_store.h" | 11 #include "chrome/browser/renderer_host/backing_store.h" |
| 11 #include "chrome/browser/renderer_host/render_process_host.h" | 12 #include "chrome/browser/renderer_host/render_process_host.h" |
| 12 #include "chrome/browser/renderer_host/render_widget_helper.h" | 13 #include "chrome/browser/renderer_host/render_widget_helper.h" |
| 13 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 14 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 14 #include "chrome/common/notification_service.h" | 15 #include "chrome/common/notification_service.h" |
| 15 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/render_messages.h" |
| 16 #include "chrome/views/view.h" | 17 #include "chrome/views/view.h" |
| 17 #include "webkit/glue/webcursor.h" | 18 #include "webkit/glue/webcursor.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 } | 299 } |
| 299 | 300 |
| 300 ForwardInputEvent(key_event, sizeof(WebKeyboardEvent)); | 301 ForwardInputEvent(key_event, sizeof(WebKeyboardEvent)); |
| 301 } | 302 } |
| 302 | 303 |
| 303 void RenderWidgetHost::ForwardInputEvent(const WebInputEvent& input_event, | 304 void RenderWidgetHost::ForwardInputEvent(const WebInputEvent& input_event, |
| 304 int event_size) { | 305 int event_size) { |
| 305 if (!process_->channel()) | 306 if (!process_->channel()) |
| 306 return; | 307 return; |
| 307 | 308 |
| 309 if (input_event.type == WebInputEvent::KEY_DOWN || | |
|
darin (slow to review)
2009/02/27 00:15:56
i think we may also need RAW_KEY_DOWN here, right?
Avi (use Gerrit)
2009/02/27 15:12:47
RAW_KEY_DOWN does not yet exist. It will once I na
| |
| 310 input_event.type == WebInputEvent::KEY_UP || | |
| 311 input_event.type == WebInputEvent::CHAR) { | |
| 312 // Put all WebKeyboardEvent objects in a queue since we can't trust the | |
| 313 // renderer and we need to give something to the UnhandledInputEvent | |
| 314 // handler. | |
| 315 key_queue_.push(static_cast<const WebKeyboardEvent&>(input_event)); | |
| 316 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size()); | |
| 317 } | |
| 318 | |
| 308 IPC::Message* message = new ViewMsg_HandleInputEvent(routing_id_); | 319 IPC::Message* message = new ViewMsg_HandleInputEvent(routing_id_); |
| 309 message->WriteData( | 320 message->WriteData( |
| 310 reinterpret_cast<const char*>(&input_event), event_size); | 321 reinterpret_cast<const char*>(&input_event), event_size); |
| 311 input_event_start_time_ = TimeTicks::Now(); | 322 input_event_start_time_ = TimeTicks::Now(); |
| 312 Send(message); | 323 Send(message); |
| 313 | 324 |
| 314 // Any input event cancels a pending mouse move event. | 325 // Any input event cancels a pending mouse move event. |
| 315 next_mouse_move_.reset(); | 326 next_mouse_move_.reset(); |
| 316 | 327 |
| 317 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); | 328 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 if (type == WebInputEvent::MOUSE_MOVE) { | 558 if (type == WebInputEvent::MOUSE_MOVE) { |
| 548 mouse_move_pending_ = false; | 559 mouse_move_pending_ = false; |
| 549 | 560 |
| 550 // now, we can send the next mouse move event | 561 // now, we can send the next mouse move event |
| 551 if (next_mouse_move_.get()) { | 562 if (next_mouse_move_.get()) { |
| 552 DCHECK(next_mouse_move_->type == WebInputEvent::MOUSE_MOVE); | 563 DCHECK(next_mouse_move_->type == WebInputEvent::MOUSE_MOVE); |
| 553 ForwardMouseEvent(*next_mouse_move_); | 564 ForwardMouseEvent(*next_mouse_move_); |
| 554 } | 565 } |
| 555 } | 566 } |
| 556 | 567 |
| 557 const char* data = NULL; | 568 if (type == WebInputEvent::KEY_DOWN || |
| 558 int length = 0; | 569 type == WebInputEvent::KEY_UP || |
| 559 if (message.ReadData(&iter, &data, &length)) { | 570 type == WebInputEvent::CHAR) { |
| 560 const WebInputEvent* input_event = | 571 if (key_queue_.size() == 0) { |
| 561 reinterpret_cast<const WebInputEvent*>(data); | 572 LOG(ERROR) << "Got a KeyEvent back from the renderer but we " |
| 562 UnhandledInputEvent(*input_event); | 573 << "don't seem to have sent it to the renderer!"; |
| 574 } else if (key_queue_.front().type != type) { | |
| 575 LOG(ERROR) << "We seem to have a different key type sent from " | |
| 576 << "the renderer. Ignoring event."; | |
| 577 } else { | |
| 578 bool processed = false; | |
| 579 r = message.ReadBool(&iter, &processed); | |
| 580 DCHECK(r); | |
| 581 | |
| 582 if (!processed) { | |
| 583 UnhandledKeyboardEvent(key_queue_.front()); | |
| 584 } | |
| 585 | |
| 586 key_queue_.pop(); | |
| 587 } | |
| 563 } | 588 } |
| 564 } | 589 } |
| 565 | 590 |
| 566 void RenderWidgetHost::OnMsgFocus() { | 591 void RenderWidgetHost::OnMsgFocus() { |
| 567 // Only the user can focus a RenderWidgetHost. | 592 // Only the user can focus a RenderWidgetHost. |
| 568 NOTREACHED(); | 593 NOTREACHED(); |
| 569 } | 594 } |
| 570 | 595 |
| 571 void RenderWidgetHost::OnMsgBlur() { | 596 void RenderWidgetHost::OnMsgBlur() { |
| 572 if (view_) { | 597 if (view_) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 | 653 |
| 629 // TODO(darin): do we need to do something else if our backing store is not | 654 // TODO(darin): do we need to do something else if our backing store is not |
| 630 // the same size as the advertised view? maybe we just assume there is a | 655 // the same size as the advertised view? maybe we just assume there is a |
| 631 // full paint on its way? | 656 // full paint on its way? |
| 632 BackingStore* backing_store = BackingStoreManager::Lookup(this); | 657 BackingStore* backing_store = BackingStoreManager::Lookup(this); |
| 633 if (!backing_store || (backing_store->size() != view_size)) | 658 if (!backing_store || (backing_store->size() != view_size)) |
| 634 return; | 659 return; |
| 635 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, | 660 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, |
| 636 dx, dy, clip_rect, view_size); | 661 dx, dy, clip_rect, view_size); |
| 637 } | 662 } |
| OLD | NEW |