| 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 <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
| 9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "content/common/webplugin_geometry.h" | 51 #include "content/common/webplugin_geometry.h" |
| 52 #include "content/public/browser/browser_thread.h" | 52 #include "content/public/browser/browser_thread.h" |
| 53 #include "content/public/browser/native_web_keyboard_event.h" | 53 #include "content/public/browser/native_web_keyboard_event.h" |
| 54 #include "content/public/browser/notification_service.h" | 54 #include "content/public/browser/notification_service.h" |
| 55 #include "content/public/browser/notification_types.h" | 55 #include "content/public/browser/notification_types.h" |
| 56 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 56 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 57 #import "content/public/browser/render_widget_host_view_mac_delegate.h" | 57 #import "content/public/browser/render_widget_host_view_mac_delegate.h" |
| 58 #include "content/public/browser/user_metrics.h" | 58 #include "content/public/browser/user_metrics.h" |
| 59 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
| 60 #include "skia/ext/platform_canvas.h" | 60 #include "skia/ext/platform_canvas.h" |
| 61 #include "skia/ext/skia_utils_mac.h" |
| 61 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 62 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
| 62 #include "third_party/WebKit/public/web/WebInputEvent.h" | 63 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 63 #include "third_party/WebKit/public/web/mac/WebInputEventFactory.h" | 64 #include "third_party/WebKit/public/web/mac/WebInputEventFactory.h" |
| 64 #import "third_party/mozilla/ComplexTextInputPanel.h" | 65 #import "third_party/mozilla/ComplexTextInputPanel.h" |
| 65 #include "ui/base/cocoa/animation_utils.h" | 66 #include "ui/base/cocoa/animation_utils.h" |
| 66 #import "ui/base/cocoa/fullscreen_window_manager.h" | 67 #import "ui/base/cocoa/fullscreen_window_manager.h" |
| 67 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" | 68 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
| 68 #include "ui/events/keycodes/keyboard_codes.h" | 69 #include "ui/events/keycodes/keyboard_codes.h" |
| 69 #include "ui/base/layout.h" | 70 #include "ui/base/layout.h" |
| 70 #include "ui/compositor/compositor.h" | 71 #include "ui/compositor/compositor.h" |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 allow_pause_for_resize_or_repaint_(true), | 525 allow_pause_for_resize_or_repaint_(true), |
| 525 is_guest_view_hack_(is_guest_view_hack), | 526 is_guest_view_hack_(is_guest_view_hack), |
| 526 weak_factory_(this), | 527 weak_factory_(this), |
| 527 fullscreen_parent_host_view_(NULL) { | 528 fullscreen_parent_host_view_(NULL) { |
| 528 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 529 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
| 529 // goes away. Since we autorelease it, our caller must put | 530 // goes away. Since we autorelease it, our caller must put |
| 530 // |GetNativeView()| into the view hierarchy right after calling us. | 531 // |GetNativeView()| into the view hierarchy right after calling us. |
| 531 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 532 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
| 532 initWithRenderWidgetHostViewMac:this] autorelease]; | 533 initWithRenderWidgetHostViewMac:this] autorelease]; |
| 533 | 534 |
| 534 // Make this view host a solid white layer when there is no content ready to | 535 // Paint this view host with |background_color_| when there is no content |
| 535 // draw. | 536 // ready to draw. |
| 536 background_layer_.reset([[CALayer alloc] init]); | 537 background_layer_.reset([[CALayer alloc] init]); |
| 537 [background_layer_ | 538 [background_layer_ |
| 538 setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; | 539 setBackgroundColor:gfx::CGColorCreateFromSkColor(background_color_)]; |
| 539 [cocoa_view_ setLayer:background_layer_]; | 540 [cocoa_view_ setLayer:background_layer_]; |
| 540 [cocoa_view_ setWantsLayer:YES]; | 541 [cocoa_view_ setWantsLayer:YES]; |
| 541 | 542 |
| 542 if (IsDelegatedRendererEnabled()) { | 543 if (IsDelegatedRendererEnabled()) { |
| 543 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 544 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
| 544 delegated_frame_host_.reset(new DelegatedFrameHost(this)); | 545 delegated_frame_host_.reset(new DelegatedFrameHost(this)); |
| 545 } | 546 } |
| 546 | 547 |
| 547 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); | 548 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); |
| 548 | 549 |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 render_widget_host_->GetRoutingID(), GetBoundsInRootWindow(), | 1526 render_widget_host_->GetRoutingID(), GetBoundsInRootWindow(), |
| 1526 GetViewBounds())); | 1527 GetViewBounds())); |
| 1527 } | 1528 } |
| 1528 } | 1529 } |
| 1529 | 1530 |
| 1530 void RenderWidgetHostViewMac::ShowDefinitionForSelection() { | 1531 void RenderWidgetHostViewMac::ShowDefinitionForSelection() { |
| 1531 RenderWidgetHostViewMacDictionaryHelper helper(this); | 1532 RenderWidgetHostViewMacDictionaryHelper helper(this); |
| 1532 helper.ShowDefinitionForSelection(); | 1533 helper.ShowDefinitionForSelection(); |
| 1533 } | 1534 } |
| 1534 | 1535 |
| 1535 void RenderWidgetHostViewMac::SetBackgroundOpaque(bool opaque) { | 1536 void RenderWidgetHostViewMac::SetBackgroundColor(SkColor color) { |
| 1536 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); | 1537 RenderWidgetHostViewBase::SetBackgroundColor(color); |
| 1537 if (render_widget_host_) | 1538 if (render_widget_host_) |
| 1538 render_widget_host_->SetBackgroundOpaque(opaque); | 1539 render_widget_host_->SetBackgroundOpaque(GetBackgroundOpaque()); |
| 1540 |
| 1541 if (background_layer_) { |
| 1542 [background_layer_ |
| 1543 setBackgroundColor:gfx::CGColorCreateFromSkColor(background_color_)]; |
| 1544 } |
| 1539 } | 1545 } |
| 1540 | 1546 |
| 1541 BrowserAccessibilityManager* | 1547 BrowserAccessibilityManager* |
| 1542 RenderWidgetHostViewMac::CreateBrowserAccessibilityManager( | 1548 RenderWidgetHostViewMac::CreateBrowserAccessibilityManager( |
| 1543 BrowserAccessibilityDelegate* delegate) { | 1549 BrowserAccessibilityDelegate* delegate) { |
| 1544 return new BrowserAccessibilityManagerMac( | 1550 return new BrowserAccessibilityManagerMac( |
| 1545 cocoa_view_, | 1551 cocoa_view_, |
| 1546 BrowserAccessibilityManagerMac::GetEmptyDocument(), | 1552 BrowserAccessibilityManagerMac::GetEmptyDocument(), |
| 1547 delegate); | 1553 delegate); |
| 1548 } | 1554 } |
| (...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3325 | 3331 |
| 3326 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3332 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3327 // regions that are not draggable. (See ControlRegionView in | 3333 // regions that are not draggable. (See ControlRegionView in |
| 3328 // native_app_window_cocoa.mm). This requires the render host view to be | 3334 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3329 // draggable by default. | 3335 // draggable by default. |
| 3330 - (BOOL)mouseDownCanMoveWindow { | 3336 - (BOOL)mouseDownCanMoveWindow { |
| 3331 return YES; | 3337 return YES; |
| 3332 } | 3338 } |
| 3333 | 3339 |
| 3334 @end | 3340 @end |
| OLD | NEW |