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" | |
62 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 61 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
63 #include "third_party/WebKit/public/web/WebInputEvent.h" | 62 #include "third_party/WebKit/public/web/WebInputEvent.h" |
64 #include "third_party/WebKit/public/web/mac/WebInputEventFactory.h" | 63 #include "third_party/WebKit/public/web/mac/WebInputEventFactory.h" |
65 #import "third_party/mozilla/ComplexTextInputPanel.h" | 64 #import "third_party/mozilla/ComplexTextInputPanel.h" |
66 #include "ui/base/cocoa/animation_utils.h" | 65 #include "ui/base/cocoa/animation_utils.h" |
67 #import "ui/base/cocoa/fullscreen_window_manager.h" | 66 #import "ui/base/cocoa/fullscreen_window_manager.h" |
68 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" | 67 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
69 #include "ui/events/keycodes/keyboard_codes.h" | 68 #include "ui/events/keycodes/keyboard_codes.h" |
70 #include "ui/base/layout.h" | 69 #include "ui/base/layout.h" |
71 #include "ui/compositor/compositor.h" | 70 #include "ui/compositor/compositor.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 is_loading_(false), | 530 is_loading_(false), |
532 allow_pause_for_resize_or_repaint_(true), | 531 allow_pause_for_resize_or_repaint_(true), |
533 weak_factory_(this), | 532 weak_factory_(this), |
534 fullscreen_parent_host_view_(NULL) { | 533 fullscreen_parent_host_view_(NULL) { |
535 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 534 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
536 // goes away. Since we autorelease it, our caller must put | 535 // goes away. Since we autorelease it, our caller must put |
537 // |GetNativeView()| into the view hierarchy right after calling us. | 536 // |GetNativeView()| into the view hierarchy right after calling us. |
538 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 537 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
539 initWithRenderWidgetHostViewMac:this] autorelease]; | 538 initWithRenderWidgetHostViewMac:this] autorelease]; |
540 | 539 |
541 // Paint this view host with |background_color_| when there is no content | 540 // Make this view host a solid white layer when there is no content ready to |
542 // ready to draw. | 541 // draw. |
543 background_layer_.reset([[CALayer alloc] init]); | 542 background_layer_.reset([[CALayer alloc] init]); |
544 [background_layer_ | 543 [background_layer_ |
545 setBackgroundColor:gfx::CGColorCreateFromSkColor(background_color_)]; | 544 setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; |
546 [cocoa_view_ setLayer:background_layer_]; | 545 [cocoa_view_ setLayer:background_layer_]; |
547 [cocoa_view_ setWantsLayer:YES]; | 546 [cocoa_view_ setWantsLayer:YES]; |
548 | 547 |
549 if (IsDelegatedRendererEnabled()) { | 548 if (IsDelegatedRendererEnabled()) { |
550 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 549 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
551 delegated_frame_host_.reset(new DelegatedFrameHost(this)); | 550 delegated_frame_host_.reset(new DelegatedFrameHost(this)); |
552 } | 551 } |
553 | 552 |
554 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); | 553 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); |
555 | 554 |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 render_widget_host_->GetRoutingID(), GetBoundsInRootWindow(), | 1521 render_widget_host_->GetRoutingID(), GetBoundsInRootWindow(), |
1523 GetViewBounds())); | 1522 GetViewBounds())); |
1524 } | 1523 } |
1525 } | 1524 } |
1526 | 1525 |
1527 void RenderWidgetHostViewMac::ShowDefinitionForSelection() { | 1526 void RenderWidgetHostViewMac::ShowDefinitionForSelection() { |
1528 RenderWidgetHostViewMacDictionaryHelper helper(this); | 1527 RenderWidgetHostViewMacDictionaryHelper helper(this); |
1529 helper.ShowDefinitionForSelection(); | 1528 helper.ShowDefinitionForSelection(); |
1530 } | 1529 } |
1531 | 1530 |
1532 void RenderWidgetHostViewMac::SetBackgroundColor(SkColor color) { | 1531 void RenderWidgetHostViewMac::SetBackgroundOpaque(bool opaque) { |
1533 RenderWidgetHostViewBase::SetBackgroundColor(color); | 1532 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); |
1534 if (render_widget_host_) | 1533 if (render_widget_host_) |
1535 render_widget_host_->SetBackgroundOpaque(GetBackgroundOpaque()); | 1534 render_widget_host_->SetBackgroundOpaque(opaque); |
1536 | |
1537 if (background_layer_) { | |
1538 [background_layer_ | |
1539 setBackgroundColor:gfx::CGColorCreateFromSkColor(background_color_)]; | |
1540 } | |
1541 } | 1535 } |
1542 | 1536 |
1543 BrowserAccessibilityManager* | 1537 BrowserAccessibilityManager* |
1544 RenderWidgetHostViewMac::CreateBrowserAccessibilityManager( | 1538 RenderWidgetHostViewMac::CreateBrowserAccessibilityManager( |
1545 BrowserAccessibilityDelegate* delegate) { | 1539 BrowserAccessibilityDelegate* delegate) { |
1546 return new BrowserAccessibilityManagerMac( | 1540 return new BrowserAccessibilityManagerMac( |
1547 cocoa_view_, | 1541 cocoa_view_, |
1548 BrowserAccessibilityManagerMac::GetEmptyDocument(), | 1542 BrowserAccessibilityManagerMac::GetEmptyDocument(), |
1549 delegate); | 1543 delegate); |
1550 } | 1544 } |
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3323 | 3317 |
3324 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3318 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3325 // regions that are not draggable. (See ControlRegionView in | 3319 // regions that are not draggable. (See ControlRegionView in |
3326 // native_app_window_cocoa.mm). This requires the render host view to be | 3320 // native_app_window_cocoa.mm). This requires the render host view to be |
3327 // draggable by default. | 3321 // draggable by default. |
3328 - (BOOL)mouseDownCanMoveWindow { | 3322 - (BOOL)mouseDownCanMoveWindow { |
3329 return YES; | 3323 return YES; |
3330 } | 3324 } |
3331 | 3325 |
3332 @end | 3326 @end |
OLD | NEW |