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