| 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_view_mac.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #include "base/histogram.h" | 7 #include "base/histogram.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/browser_trial.h" | 10 #include "chrome/browser/browser_trial.h" |
| 11 #import "chrome/browser/cocoa/rwhvm_editcommand_helper.h" | 11 #import "chrome/browser/cocoa/rwhvm_editcommand_helper.h" |
| 12 #include "chrome/browser/renderer_host/backing_store.h" | 12 #include "chrome/browser/renderer_host/backing_store.h" |
| 13 #include "chrome/browser/renderer_host/render_process_host.h" | 13 #include "chrome/browser/renderer_host/render_process_host.h" |
| 14 #include "chrome/browser/renderer_host/render_widget_host.h" | 14 #include "chrome/browser/renderer_host/render_widget_host.h" |
| 15 #include "chrome/browser/spellchecker_platform_engine.h" | 15 #include "chrome/browser/spellchecker_platform_engine.h" |
| 16 #include "chrome/common/native_web_keyboard_event.h" | 16 #include "chrome/common/native_web_keyboard_event.h" |
| 17 #include "chrome/common/render_messages.h" |
| 17 #include "skia/ext/platform_canvas.h" | 18 #include "skia/ext/platform_canvas.h" |
| 18 #include "webkit/api/public/mac/WebInputEventFactory.h" | 19 #include "webkit/api/public/mac/WebInputEventFactory.h" |
| 19 #include "webkit/api/public/WebInputEvent.h" | 20 #include "webkit/api/public/WebInputEvent.h" |
| 20 #include "webkit/glue/webmenurunner_mac.h" | 21 #include "webkit/glue/webmenurunner_mac.h" |
| 21 | 22 |
| 22 using WebKit::WebInputEventFactory; | 23 using WebKit::WebInputEventFactory; |
| 23 using WebKit::WebMouseEvent; | 24 using WebKit::WebMouseEvent; |
| 24 using WebKit::WebMouseWheelEvent; | 25 using WebKit::WebMouseWheelEvent; |
| 25 | 26 |
| 26 @interface RenderWidgetHostViewCocoa (Private) | 27 @interface RenderWidgetHostViewCocoa (Private) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 49 | 50 |
| 50 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) | 51 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) |
| 51 : render_widget_host_(widget), | 52 : render_widget_host_(widget), |
| 52 about_to_validate_and_paint_(false), | 53 about_to_validate_and_paint_(false), |
| 53 im_attributes_(nil), | 54 im_attributes_(nil), |
| 54 im_composing_(false), | 55 im_composing_(false), |
| 55 is_loading_(false), | 56 is_loading_(false), |
| 56 is_hidden_(false), | 57 is_hidden_(false), |
| 57 shutdown_factory_(this), | 58 shutdown_factory_(this), |
| 58 parent_view_(NULL) { | 59 parent_view_(NULL) { |
| 60 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| goes away. |
| 61 // Since we autorelease it, our caller must put |native_view()| into the view |
| 62 // hierarchy right after calling us. |
| 59 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 63 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
| 60 initWithRenderWidgetHostViewMac:this] autorelease]; | 64 initWithRenderWidgetHostViewMac:this] autorelease]; |
| 61 render_widget_host_->set_view(this); | 65 render_widget_host_->set_view(this); |
| 62 } | 66 } |
| 63 | 67 |
| 64 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { | 68 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
| 65 [im_attributes_ release]; | 69 [im_attributes_ release]; |
| 66 } | 70 } |
| 67 | 71 |
| 68 /////////////////////////////////////////////////////////////////////////////// | 72 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 416 |
| 413 NSRect bounds = [[cocoa_view_ window] frame]; | 417 NSRect bounds = [[cocoa_view_ window] frame]; |
| 414 return NSRectToRect(bounds, [[cocoa_view_ window] screen]); | 418 return NSRectToRect(bounds, [[cocoa_view_ window] screen]); |
| 415 } | 419 } |
| 416 | 420 |
| 417 void RenderWidgetHostViewMac::SetActive(bool active) { | 421 void RenderWidgetHostViewMac::SetActive(bool active) { |
| 418 if (render_widget_host_) | 422 if (render_widget_host_) |
| 419 render_widget_host_->SetActive(active); | 423 render_widget_host_->SetActive(active); |
| 420 } | 424 } |
| 421 | 425 |
| 426 void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) { |
| 427 RenderWidgetHostView::SetBackground(background); |
| 428 if (render_widget_host_) |
| 429 render_widget_host_->Send(new ViewMsg_SetBackground( |
| 430 render_widget_host_->routing_id(), background)); |
| 431 } |
| 422 | 432 |
| 423 // RenderWidgetHostViewCocoa --------------------------------------------------- | 433 // RenderWidgetHostViewCocoa --------------------------------------------------- |
| 424 | 434 |
| 425 @implementation RenderWidgetHostViewCocoa | 435 @implementation RenderWidgetHostViewCocoa |
| 426 | 436 |
| 427 // Tons of stuff goes here, where we grab events going on in Cocoaland and send | 437 // Tons of stuff goes here, where we grab events going on in Cocoaland and send |
| 428 // them into the C++ system. TODO(avi): all that jazz | 438 // them into the C++ system. TODO(avi): all that jazz |
| 429 | 439 |
| 430 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { | 440 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { |
| 431 self = [super initWithFrame:NSZeroRect]; | 441 self = [super initWithFrame:NSZeroRect]; |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); | 1157 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); |
| 1148 } else { | 1158 } else { |
| 1149 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( | 1159 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( |
| 1150 UTF8ToUTF16([im_text UTF8String])); | 1160 UTF8ToUTF16([im_text UTF8String])); |
| 1151 } | 1161 } |
| 1152 renderWidgetHostView_->im_composing_ = false; | 1162 renderWidgetHostView_->im_composing_ = false; |
| 1153 } | 1163 } |
| 1154 | 1164 |
| 1155 @end | 1165 @end |
| 1156 | 1166 |
| OLD | NEW |