| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/histogram.h" | 7 #include "base/histogram.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/keyboard_codes.h" | 9 #include "base/keyboard_codes.h" |
| 10 #include "chrome/browser/renderer_host/backing_store.h" | 10 #include "chrome/browser/renderer_host/backing_store.h" |
| 11 #include "chrome/browser/renderer_host/backing_store_manager.h" | 11 #include "chrome/browser/renderer_host/backing_store_manager.h" |
| 12 #include "chrome/browser/renderer_host/render_process_host.h" | 12 #include "chrome/browser/renderer_host/render_process_host.h" |
| 13 #include "chrome/browser/renderer_host/render_widget_helper.h" | 13 #include "chrome/browser/renderer_host/render_widget_helper.h" |
| 14 #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h" | 14 #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h" |
| 15 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 15 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 16 #include "chrome/common/notification_service.h" | 16 #include "chrome/common/notification_service.h" |
| 17 #include "chrome/common/render_messages.h" | 17 #include "chrome/common/render_messages.h" |
| 18 #include "views/view.h" | 18 #include "views/view.h" |
| 19 #include "webkit/glue/webcursor.h" | 19 #include "webkit/glue/webcursor.h" |
| 20 #include "webkit/glue/webtextdirection.h" | |
| 21 | 20 |
| 22 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 23 #include "base/gfx/gdi_util.h" | 22 #include "base/gfx/gdi_util.h" |
| 24 #include "chrome/app/chrome_dll_resource.h" | 23 #include "chrome/app/chrome_dll_resource.h" |
| 25 #endif // defined(OS_WIN) | 24 #endif // defined(OS_WIN) |
| 26 | 25 |
| 27 #if defined (OS_MACOSX) | 26 #if defined (OS_MACOSX) |
| 28 #include "webkit/api/public/WebScreenInfo.h" | 27 #include "webkit/api/public/WebScreenInfo.h" |
| 29 #include "webkit/api/public/mac/WebScreenInfoFactory.h" | 28 #include "webkit/api/public/mac/WebScreenInfoFactory.h" |
| 30 #endif | 29 #endif |
| 31 | 30 |
| 32 using base::Time; | 31 using base::Time; |
| 33 using base::TimeDelta; | 32 using base::TimeDelta; |
| 34 using base::TimeTicks; | 33 using base::TimeTicks; |
| 35 | 34 |
| 36 using WebKit::WebInputEvent; | 35 using WebKit::WebInputEvent; |
| 37 using WebKit::WebKeyboardEvent; | 36 using WebKit::WebKeyboardEvent; |
| 38 using WebKit::WebMouseEvent; | 37 using WebKit::WebMouseEvent; |
| 39 using WebKit::WebMouseWheelEvent; | 38 using WebKit::WebMouseWheelEvent; |
| 39 using WebKit::WebTextDirection; |
| 40 | 40 |
| 41 #if defined (OS_MACOSX) | 41 #if defined (OS_MACOSX) |
| 42 using WebKit::WebScreenInfo; | 42 using WebKit::WebScreenInfo; |
| 43 using WebKit::WebScreenInfoFactory; | 43 using WebKit::WebScreenInfoFactory; |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 // How long to (synchronously) wait for the renderer to respond with a | 46 // How long to (synchronously) wait for the renderer to respond with a |
| 47 // PaintRect message, when our backing-store is invalid, before giving up and | 47 // PaintRect message, when our backing-store is invalid, before giving up and |
| 48 // returning a null or incorrectly sized backing-store from GetBackingStore. | 48 // returning a null or incorrectly sized backing-store from GetBackingStore. |
| 49 // This timeout impacts the "choppiness" of our window resize perf. | 49 // This timeout impacts the "choppiness" of our window resize perf. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 65 is_loading_(false), | 65 is_loading_(false), |
| 66 is_hidden_(false), | 66 is_hidden_(false), |
| 67 repaint_ack_pending_(false), | 67 repaint_ack_pending_(false), |
| 68 resize_ack_pending_(false), | 68 resize_ack_pending_(false), |
| 69 mouse_move_pending_(false), | 69 mouse_move_pending_(false), |
| 70 needs_repainting_on_restore_(false), | 70 needs_repainting_on_restore_(false), |
| 71 is_unresponsive_(false), | 71 is_unresponsive_(false), |
| 72 in_get_backing_store_(false), | 72 in_get_backing_store_(false), |
| 73 view_being_painted_(false), | 73 view_being_painted_(false), |
| 74 text_direction_updated_(false), | 74 text_direction_updated_(false), |
| 75 text_direction_(WEB_TEXT_DIRECTION_LTR), | 75 text_direction_(WebKit::WebTextDirectionLeftToRight), |
| 76 text_direction_canceled_(false) { | 76 text_direction_canceled_(false) { |
| 77 if (routing_id_ == MSG_ROUTING_NONE) | 77 if (routing_id_ == MSG_ROUTING_NONE) |
| 78 routing_id_ = process_->GetNextRoutingID(); | 78 routing_id_ = process_->GetNextRoutingID(); |
| 79 | 79 |
| 80 process_->Attach(this, routing_id_); | 80 process_->Attach(this, routing_id_); |
| 81 // Because the widget initializes as is_hidden_ == false, | 81 // Because the widget initializes as is_hidden_ == false, |
| 82 // tell the process host that we're alive. | 82 // tell the process host that we're alive. |
| 83 process_->WidgetRestored(); | 83 process_->WidgetRestored(); |
| 84 } | 84 } |
| 85 | 85 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 } | 445 } |
| 446 | 446 |
| 447 void RenderWidgetHost::CancelUpdateTextDirection() { | 447 void RenderWidgetHost::CancelUpdateTextDirection() { |
| 448 if (text_direction_updated_) | 448 if (text_direction_updated_) |
| 449 text_direction_canceled_ = true; | 449 text_direction_canceled_ = true; |
| 450 } | 450 } |
| 451 | 451 |
| 452 void RenderWidgetHost::NotifyTextDirection() { | 452 void RenderWidgetHost::NotifyTextDirection() { |
| 453 if (text_direction_updated_) { | 453 if (text_direction_updated_) { |
| 454 if (!text_direction_canceled_) | 454 if (!text_direction_canceled_) |
| 455 Send(new ViewMsg_SetTextDirection(routing_id(), | 455 Send(new ViewMsg_SetTextDirection(routing_id(), text_direction_)); |
| 456 static_cast<int>(text_direction_))); | |
| 457 text_direction_updated_ = false; | 456 text_direction_updated_ = false; |
| 458 text_direction_canceled_ = false; | 457 text_direction_canceled_ = false; |
| 459 } | 458 } |
| 460 } | 459 } |
| 461 | 460 |
| 462 void RenderWidgetHost::ImeSetInputMode(bool activate) { | 461 void RenderWidgetHost::ImeSetInputMode(bool activate) { |
| 463 Send(new ViewMsg_ImeSetInputMode(routing_id(), activate)); | 462 Send(new ViewMsg_ImeSetInputMode(routing_id(), activate)); |
| 464 } | 463 } |
| 465 | 464 |
| 466 void RenderWidgetHost::ImeSetComposition(const std::wstring& ime_string, | 465 void RenderWidgetHost::ImeSetComposition(const string16& ime_string, |
| 467 int cursor_position, | 466 int cursor_position, |
| 468 int target_start, | 467 int target_start, |
| 469 int target_end) { | 468 int target_end) { |
| 470 Send(new ViewMsg_ImeSetComposition(routing_id(), 0, cursor_position, | 469 Send(new ViewMsg_ImeSetComposition(routing_id(), |
| 471 target_start, target_end, ime_string)); | 470 WebKit::WebCompositionCommandSet, |
| 471 cursor_position, target_start, target_end, |
| 472 ime_string)); |
| 472 } | 473 } |
| 473 | 474 |
| 474 void RenderWidgetHost::ImeConfirmComposition(const std::wstring& ime_string) { | 475 void RenderWidgetHost::ImeConfirmComposition(const string16& ime_string) { |
| 475 Send(new ViewMsg_ImeSetComposition(routing_id(), 1, -1, -1, -1, ime_string)); | 476 Send(new ViewMsg_ImeSetComposition(routing_id(), |
| 477 WebKit::WebCompositionCommandConfirm, |
| 478 -1, -1, -1, ime_string)); |
| 476 } | 479 } |
| 477 | 480 |
| 478 void RenderWidgetHost::ImeCancelComposition() { | 481 void RenderWidgetHost::ImeCancelComposition() { |
| 479 std::wstring empty_string; | 482 Send(new ViewMsg_ImeSetComposition(routing_id(), |
| 480 Send(new ViewMsg_ImeSetComposition(routing_id(), -1, -1, -1, -1, | 483 WebKit::WebCompositionCommandDiscard, |
| 481 empty_string)); | 484 -1, -1, -1, string16())); |
| 482 } | 485 } |
| 483 | 486 |
| 484 gfx::Rect RenderWidgetHost::GetRootWindowResizerRect() const { | 487 gfx::Rect RenderWidgetHost::GetRootWindowResizerRect() const { |
| 485 return gfx::Rect(); | 488 return gfx::Rect(); |
| 486 } | 489 } |
| 487 | 490 |
| 488 void RenderWidgetHost::Destroy() { | 491 void RenderWidgetHost::Destroy() { |
| 489 NotificationService::current()->Notify( | 492 NotificationService::current()->Notify( |
| 490 NotificationType::RENDER_WIDGET_HOST_DESTROYED, | 493 NotificationType::RENDER_WIDGET_HOST_DESTROYED, |
| 491 Source<RenderWidgetHost>(this), | 494 Source<RenderWidgetHost>(this), |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 | 851 |
| 849 // TODO(darin): do we need to do something else if our backing store is not | 852 // TODO(darin): do we need to do something else if our backing store is not |
| 850 // the same size as the advertised view? maybe we just assume there is a | 853 // the same size as the advertised view? maybe we just assume there is a |
| 851 // full paint on its way? | 854 // full paint on its way? |
| 852 BackingStore* backing_store = BackingStoreManager::Lookup(this); | 855 BackingStore* backing_store = BackingStoreManager::Lookup(this); |
| 853 if (!backing_store || (backing_store->size() != view_size)) | 856 if (!backing_store || (backing_store->size() != view_size)) |
| 854 return; | 857 return; |
| 855 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, | 858 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, |
| 856 dx, dy, clip_rect, view_size); | 859 dx, dy, clip_rect, view_size); |
| 857 } | 860 } |
| OLD | NEW |