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 #import "chrome/browser/cocoa/rwhvm_editcommand_helper.h" | 10 #import "chrome/browser/cocoa/rwhvm_editcommand_helper.h" |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 443 |
444 CGRect paint_rect_cg = paint_rect.ToCGRect(); | 444 CGRect paint_rect_cg = paint_rect.ToCGRect(); |
445 NSRect paint_rect_ns = [self RectToNSRect:paint_rect]; | 445 NSRect paint_rect_ns = [self RectToNSRect:paint_rect]; |
446 canvas->getTopPlatformDevice().DrawToContext( | 446 canvas->getTopPlatformDevice().DrawToContext( |
447 context, paint_rect_ns.origin.x, paint_rect_ns.origin.y, | 447 context, paint_rect_ns.origin.x, paint_rect_ns.origin.y, |
448 &paint_rect_cg); | 448 &paint_rect_cg); |
449 } | 449 } |
450 | 450 |
451 // Fill the remaining portion of the damaged_rect with white | 451 // Fill the remaining portion of the damaged_rect with white |
452 if (damaged_rect.right() > bitmap_rect.right()) { | 452 if (damaged_rect.right() > bitmap_rect.right()) { |
453 NSRect r; | 453 int x = std::max(bitmap_rect.right(), damaged_rect.x()); |
454 r.origin.x = std::max(bitmap_rect.right(), damaged_rect.x()); | 454 int y = std::min(bitmap_rect.bottom(), damaged_rect.bottom()); |
455 r.origin.y = std::min(bitmap_rect.bottom(), damaged_rect.bottom()); | 455 int width = damaged_rect.right() - x; |
456 r.size.width = damaged_rect.right() - r.origin.x; | 456 int height = damaged_rect.y() - y; |
457 r.size.height = damaged_rect.y() - r.origin.y; | 457 |
| 458 // Extra fun to get around the fact that gfx::Rects can't have |
| 459 // negative sizes. |
| 460 if (width < 0) { |
| 461 x += width; |
| 462 width = -width; |
| 463 } |
| 464 if (height < 0) { |
| 465 y += height; |
| 466 height = -height; |
| 467 } |
| 468 |
| 469 NSRect r = [self RectToNSRect:gfx::Rect(x, y, width, height)]; |
458 [[NSColor whiteColor] set]; | 470 [[NSColor whiteColor] set]; |
459 NSRectFill(r); | 471 NSRectFill(r); |
460 } | 472 } |
461 if (damaged_rect.bottom() > bitmap_rect.bottom()) { | 473 if (damaged_rect.bottom() > bitmap_rect.bottom()) { |
462 NSRect r; | 474 int x = damaged_rect.x(); |
463 r.origin.x = damaged_rect.x(); | 475 int y = damaged_rect.bottom(); |
464 r.origin.y = damaged_rect.bottom(); | 476 int width = damaged_rect.right() - x; |
465 r.size.width = damaged_rect.right() - r.origin.x; | 477 int height = std::max(bitmap_rect.bottom(), damaged_rect.y()) - y; |
466 r.size.height = std::max(bitmap_rect.bottom(), damaged_rect.y()) - | 478 |
467 r.origin.y; | 479 // Extra fun to get around the fact that gfx::Rects can't have |
| 480 // negative sizes. |
| 481 if (width < 0) { |
| 482 x += width; |
| 483 width = -width; |
| 484 } |
| 485 if (height < 0) { |
| 486 y += height; |
| 487 height = -height; |
| 488 } |
| 489 |
| 490 NSRect r = [self RectToNSRect:gfx::Rect(x, y, width, height)]; |
468 [[NSColor whiteColor] set]; | 491 [[NSColor whiteColor] set]; |
469 NSRectFill(r); | 492 NSRectFill(r); |
470 } | 493 } |
471 if (!renderWidgetHostView_->whiteout_start_time_.is_null()) { | 494 if (!renderWidgetHostView_->whiteout_start_time_.is_null()) { |
472 base::TimeDelta whiteout_duration = base::TimeTicks::Now() - | 495 base::TimeDelta whiteout_duration = base::TimeTicks::Now() - |
473 renderWidgetHostView_->whiteout_start_time_; | 496 renderWidgetHostView_->whiteout_start_time_; |
474 UMA_HISTOGRAM_TIMES("MPArch.RWHH_WhiteoutDuration", whiteout_duration); | 497 UMA_HISTOGRAM_TIMES("MPArch.RWHH_WhiteoutDuration", whiteout_duration); |
475 | 498 |
476 // Reset the start time to 0 so that we start recording again the next | 499 // Reset the start time to 0 so that we start recording again the next |
477 // time the backing store is NULL... | 500 // time the backing store is NULL... |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 546 |
524 return editCommand_helper_->IsMenuItemEnabled(action, self); | 547 return editCommand_helper_->IsMenuItemEnabled(action, self); |
525 } | 548 } |
526 | 549 |
527 - (RenderWidgetHostViewMac*)renderWidgetHostViewMac { | 550 - (RenderWidgetHostViewMac*)renderWidgetHostViewMac { |
528 return renderWidgetHostView_; | 551 return renderWidgetHostView_; |
529 } | 552 } |
530 | 553 |
531 @end | 554 @end |
532 | 555 |
OLD | NEW |