| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 #import <objc/runtime.h> | 8 #import <objc/runtime.h> |
| 9 #include <OpenGL/gl.h> | 9 #include <OpenGL/gl.h> |
| 10 #include <QuartzCore/QuartzCore.h> | 10 #include <QuartzCore/QuartzCore.h> |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 bool is_guest_view_hack) | 447 bool is_guest_view_hack) |
| 448 : render_widget_host_(RenderWidgetHostImpl::From(widget)), | 448 : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
| 449 page_at_minimum_scale_(true), | 449 page_at_minimum_scale_(true), |
| 450 is_loading_(false), | 450 is_loading_(false), |
| 451 allow_pause_for_resize_or_repaint_(true), | 451 allow_pause_for_resize_or_repaint_(true), |
| 452 is_guest_view_hack_(is_guest_view_hack), | 452 is_guest_view_hack_(is_guest_view_hack), |
| 453 fullscreen_parent_host_view_(nullptr), | 453 fullscreen_parent_host_view_(nullptr), |
| 454 needs_flush_input_(false), | 454 needs_flush_input_(false), |
| 455 selection_text_offset_(0), | 455 selection_text_offset_(0), |
| 456 selection_range_(gfx::Range::InvalidRange()), | 456 selection_range_(gfx::Range::InvalidRange()), |
| 457 background_color_(SK_ColorWHITE), |
| 457 weak_factory_(this) { | 458 weak_factory_(this) { |
| 458 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 459 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
| 459 // goes away. Since we autorelease it, our caller must put | 460 // goes away. Since we autorelease it, our caller must put |
| 460 // |GetNativeView()| into the view hierarchy right after calling us. | 461 // |GetNativeView()| into the view hierarchy right after calling us. |
| 461 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 462 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
| 462 initWithRenderWidgetHostViewMac:this] autorelease]; | 463 initWithRenderWidgetHostViewMac:this] autorelease]; |
| 463 | 464 |
| 464 // Paint this view host with |background_color_| when there is no content | 465 // Paint this view host with |background_color_| when there is no content |
| 465 // ready to draw. | 466 // ready to draw. |
| 466 background_layer_.reset([[CALayer alloc] init]); | 467 background_layer_.reset([[CALayer alloc] init]); |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 } | 1624 } |
| 1624 | 1625 |
| 1625 void RenderWidgetHostViewMac::ShowDefinitionForSelection() { | 1626 void RenderWidgetHostViewMac::ShowDefinitionForSelection() { |
| 1626 RenderWidgetHostViewMacDictionaryHelper helper(this); | 1627 RenderWidgetHostViewMacDictionaryHelper helper(this); |
| 1627 helper.ShowDefinitionForSelection(); | 1628 helper.ShowDefinitionForSelection(); |
| 1628 } | 1629 } |
| 1629 | 1630 |
| 1630 void RenderWidgetHostViewMac::SetBackgroundColor(SkColor color) { | 1631 void RenderWidgetHostViewMac::SetBackgroundColor(SkColor color) { |
| 1631 if (color == background_color_) | 1632 if (color == background_color_) |
| 1632 return; | 1633 return; |
| 1634 background_color_ = color; |
| 1633 | 1635 |
| 1634 RenderWidgetHostViewBase::SetBackgroundColor(color); | 1636 DCHECK(SkColorGetA(color) == SK_AlphaOPAQUE || |
| 1635 bool opaque = GetBackgroundOpaque(); | 1637 SkColorGetA(color) == SK_AlphaTRANSPARENT); |
| 1638 bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE; |
| 1636 | 1639 |
| 1637 if (render_widget_host_) | 1640 if (render_widget_host_) |
| 1638 render_widget_host_->SetBackgroundOpaque(opaque); | 1641 render_widget_host_->SetBackgroundOpaque(opaque); |
| 1639 | 1642 |
| 1640 [cocoa_view_ setOpaque:opaque]; | 1643 [cocoa_view_ setOpaque:opaque]; |
| 1641 | 1644 |
| 1642 browser_compositor_->SetHasTransparentBackground(!opaque); | 1645 browser_compositor_->SetHasTransparentBackground(!opaque); |
| 1643 | 1646 |
| 1644 ScopedCAActionDisabler disabler; | 1647 ScopedCAActionDisabler disabler; |
| 1645 base::ScopedCFTypeRef<CGColorRef> cg_color( | 1648 base::ScopedCFTypeRef<CGColorRef> cg_color( |
| 1646 skia::CGColorCreateFromSkColor(color)); | 1649 skia::CGColorCreateFromSkColor(color)); |
| 1647 [background_layer_ setBackgroundColor:cg_color]; | 1650 [background_layer_ setBackgroundColor:cg_color]; |
| 1648 } | 1651 } |
| 1649 | 1652 |
| 1653 SkColor RenderWidgetHostViewMac::background_color() const { |
| 1654 return background_color_; |
| 1655 } |
| 1656 |
| 1650 BrowserAccessibilityManager* | 1657 BrowserAccessibilityManager* |
| 1651 RenderWidgetHostViewMac::CreateBrowserAccessibilityManager( | 1658 RenderWidgetHostViewMac::CreateBrowserAccessibilityManager( |
| 1652 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { | 1659 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { |
| 1653 return new BrowserAccessibilityManagerMac( | 1660 return new BrowserAccessibilityManagerMac( |
| 1654 cocoa_view_, | 1661 cocoa_view_, |
| 1655 BrowserAccessibilityManagerMac::GetEmptyDocument(), | 1662 BrowserAccessibilityManagerMac::GetEmptyDocument(), |
| 1656 delegate); | 1663 delegate); |
| 1657 } | 1664 } |
| 1658 | 1665 |
| 1659 gfx::Point RenderWidgetHostViewMac::AccessibilityOriginInScreen( | 1666 gfx::Point RenderWidgetHostViewMac::AccessibilityOriginInScreen( |
| (...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3461 | 3468 |
| 3462 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3469 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3463 // regions that are not draggable. (See ControlRegionView in | 3470 // regions that are not draggable. (See ControlRegionView in |
| 3464 // native_app_window_cocoa.mm). This requires the render host view to be | 3471 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3465 // draggable by default. | 3472 // draggable by default. |
| 3466 - (BOOL)mouseDownCanMoveWindow { | 3473 - (BOOL)mouseDownCanMoveWindow { |
| 3467 return YES; | 3474 return YES; |
| 3468 } | 3475 } |
| 3469 | 3476 |
| 3470 @end | 3477 @end |
| OLD | NEW |