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/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/browser_trial.h" | 9 #include "chrome/browser/browser_trial.h" |
10 #include "chrome/browser/renderer_host/backing_store.h" | 10 #include "chrome/browser/renderer_host/backing_store.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (tooltip_text_.length() > kMaxTooltipLength) | 260 if (tooltip_text_.length() > kMaxTooltipLength) |
261 tooltip_text_ = tooltip_text_.substr(0, kMaxTooltipLength); | 261 tooltip_text_ = tooltip_text_.substr(0, kMaxTooltipLength); |
262 | 262 |
263 NSString* tooltip_nsstring = base::SysWideToNSString(tooltip_text_); | 263 NSString* tooltip_nsstring = base::SysWideToNSString(tooltip_text_); |
264 [cocoa_view_ setToolTip:tooltip_nsstring]; | 264 [cocoa_view_ setToolTip:tooltip_nsstring]; |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 BackingStore* RenderWidgetHostViewMac::AllocBackingStore( | 268 BackingStore* RenderWidgetHostViewMac::AllocBackingStore( |
269 const gfx::Size& size) { | 269 const gfx::Size& size) { |
270 return new BackingStore(size); | 270 return new BackingStore(render_widget_host_, size); |
271 } | 271 } |
272 | 272 |
273 // Display a popup menu for WebKit using Cocoa widgets. | 273 // Display a popup menu for WebKit using Cocoa widgets. |
274 void RenderWidgetHostViewMac::ShowPopupWithItems( | 274 void RenderWidgetHostViewMac::ShowPopupWithItems( |
275 gfx::Rect bounds, | 275 gfx::Rect bounds, |
276 int item_height, | 276 int item_height, |
277 int selected_item, | 277 int selected_item, |
278 const std::vector<WebMenuItem>& items) { | 278 const std::vector<WebMenuItem>& items) { |
279 NSRect view_rect = [cocoa_view_ bounds]; | 279 NSRect view_rect = [cocoa_view_ bounds]; |
280 NSRect parent_rect = [parent_view_ bounds]; | 280 NSRect parent_rect = [parent_view_ bounds]; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 renderWidgetHostView_->render_widget_host_->WasResized(); | 378 renderWidgetHostView_->render_widget_host_->WasResized(); |
379 } | 379 } |
380 | 380 |
381 - (void)drawRect:(NSRect)dirtyRect { | 381 - (void)drawRect:(NSRect)dirtyRect { |
382 DCHECK(renderWidgetHostView_->render_widget_host_->process()->channel()); | 382 DCHECK(renderWidgetHostView_->render_widget_host_->process()->channel()); |
383 DCHECK(!renderWidgetHostView_->about_to_validate_and_paint_); | 383 DCHECK(!renderWidgetHostView_->about_to_validate_and_paint_); |
384 | 384 |
385 renderWidgetHostView_->invalid_rect_ = dirtyRect; | 385 renderWidgetHostView_->invalid_rect_ = dirtyRect; |
386 renderWidgetHostView_->about_to_validate_and_paint_ = true; | 386 renderWidgetHostView_->about_to_validate_and_paint_ = true; |
387 BackingStore* backing_store = | 387 BackingStore* backing_store = |
388 renderWidgetHostView_->render_widget_host_->GetBackingStore(); | 388 renderWidgetHostView_->render_widget_host_->GetBackingStore(true); |
389 skia::PlatformCanvas* canvas = backing_store->canvas(); | 389 skia::PlatformCanvas* canvas = backing_store->canvas(); |
390 renderWidgetHostView_->about_to_validate_and_paint_ = false; | 390 renderWidgetHostView_->about_to_validate_and_paint_ = false; |
391 dirtyRect = renderWidgetHostView_->invalid_rect_; | 391 dirtyRect = renderWidgetHostView_->invalid_rect_; |
392 | 392 |
393 if (backing_store) { | 393 if (backing_store) { |
394 gfx::Rect damaged_rect([self NSRectToRect:dirtyRect]); | 394 gfx::Rect damaged_rect([self NSRectToRect:dirtyRect]); |
395 | 395 |
396 gfx::Rect bitmap_rect(0, 0, | 396 gfx::Rect bitmap_rect(0, 0, |
397 backing_store->size().width(), | 397 backing_store->size().width(), |
398 backing_store->size().height()); | 398 backing_store->size().height()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 452 |
453 - (BOOL)acceptsFirstResponder { | 453 - (BOOL)acceptsFirstResponder { |
454 return canBeKeyView_; | 454 return canBeKeyView_; |
455 } | 455 } |
456 | 456 |
457 - (BOOL)becomeFirstResponder { | 457 - (BOOL)becomeFirstResponder { |
458 if (![self superview]) { | 458 if (![self superview]) { |
459 // We're dead, so becoming first responder is probably a bad idea. | 459 // We're dead, so becoming first responder is probably a bad idea. |
460 return NO; | 460 return NO; |
461 } | 461 } |
462 | 462 |
463 renderWidgetHostView_->render_widget_host_->Focus(); | 463 renderWidgetHostView_->render_widget_host_->Focus(); |
464 return YES; | 464 return YES; |
465 } | 465 } |
466 | 466 |
467 - (BOOL)resignFirstResponder { | 467 - (BOOL)resignFirstResponder { |
468 if (![self superview]) { | 468 if (![self superview]) { |
469 // We're dead, so touching renderWidgetHostView_ is probably a bad | 469 // We're dead, so touching renderWidgetHostView_ is probably a bad |
470 // idea. | 470 // idea. |
471 return YES; | 471 return YES; |
472 } | 472 } |
473 | 473 |
474 if (closeOnDeactivate_) | 474 if (closeOnDeactivate_) |
475 renderWidgetHostView_->KillSelf(); | 475 renderWidgetHostView_->KillSelf(); |
476 | 476 |
477 renderWidgetHostView_->render_widget_host_->Blur(); | 477 renderWidgetHostView_->render_widget_host_->Blur(); |
478 | 478 |
479 return YES; | 479 return YES; |
480 } | 480 } |
481 | 481 |
482 @end | 482 @end |
OLD | NEW |