| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 [flipped_layer_ | 530 [flipped_layer_ |
| 531 setAutoresizingMask:kCALayerWidthSizable|kCALayerHeightSizable]; | 531 setAutoresizingMask:kCALayerWidthSizable|kCALayerHeightSizable]; |
| 532 [background_layer_ addSublayer:flipped_layer_]; | 532 [background_layer_ addSublayer:flipped_layer_]; |
| 533 } | 533 } |
| 534 | 534 |
| 535 if (IsDelegatedRendererEnabled()) { | 535 if (IsDelegatedRendererEnabled()) { |
| 536 root_layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); | 536 root_layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); |
| 537 delegated_frame_host_.reset(new DelegatedFrameHost(this)); | 537 delegated_frame_host_.reset(new DelegatedFrameHost(this)); |
| 538 } | 538 } |
| 539 | 539 |
| 540 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); |
| 541 |
| 540 render_widget_host_->SetView(this); | 542 render_widget_host_->SetView(this); |
| 541 } | 543 } |
| 542 | 544 |
| 543 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { | 545 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
| 546 gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this); |
| 547 |
| 544 // This is being called from |cocoa_view_|'s destructor, so invalidate the | 548 // This is being called from |cocoa_view_|'s destructor, so invalidate the |
| 545 // pointer. | 549 // pointer. |
| 546 cocoa_view_ = nil; | 550 cocoa_view_ = nil; |
| 547 | 551 |
| 548 UnlockMouse(); | 552 UnlockMouse(); |
| 549 | 553 |
| 550 // Make sure that the layer doesn't reach into the now-invalid object. | 554 // Make sure that the layer doesn't reach into the now-invalid object. |
| 551 DestroyCompositedIOSurfaceAndLayer(); | 555 DestroyCompositedIOSurfaceAndLayer(); |
| 552 DestroySoftwareLayer(); | 556 DestroySoftwareLayer(); |
| 553 | 557 |
| (...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame(bool succeeded) { | 2260 void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame(bool succeeded) { |
| 2257 if (!render_widget_host_) | 2261 if (!render_widget_host_) |
| 2258 return; | 2262 return; |
| 2259 | 2263 |
| 2260 SendPendingLatencyInfoToHost(); | 2264 SendPendingLatencyInfoToHost(); |
| 2261 SendPendingSwapAck(); | 2265 SendPendingSwapAck(); |
| 2262 if (!succeeded) | 2266 if (!succeeded) |
| 2263 GotAcceleratedCompositingError(); | 2267 GotAcceleratedCompositingError(); |
| 2264 } | 2268 } |
| 2265 | 2269 |
| 2270 //////////////////////////////////////////////////////////////////////////////// |
| 2271 // gfx::DisplayObserver, public: |
| 2272 |
| 2273 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) { |
| 2274 } |
| 2275 |
| 2276 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) { |
| 2277 } |
| 2278 |
| 2279 void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| 2280 const gfx::Display& display, uint32_t metrics) { |
| 2281 gfx::Screen* screen = gfx::Screen::GetScreenFor(cocoa_view_); |
| 2282 if (display.id() != screen->GetDisplayNearestWindow(cocoa_view_).id()) |
| 2283 return; |
| 2284 |
| 2285 UpdateScreenInfo(cocoa_view_); |
| 2286 } |
| 2287 |
| 2266 } // namespace content | 2288 } // namespace content |
| 2267 | 2289 |
| 2268 // RenderWidgetHostViewCocoa --------------------------------------------------- | 2290 // RenderWidgetHostViewCocoa --------------------------------------------------- |
| 2269 | 2291 |
| 2270 @implementation RenderWidgetHostViewCocoa | 2292 @implementation RenderWidgetHostViewCocoa |
| 2271 @synthesize selectedRange = selectedRange_; | 2293 @synthesize selectedRange = selectedRange_; |
| 2272 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_; | 2294 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_; |
| 2273 @synthesize markedRange = markedRange_; | 2295 @synthesize markedRange = markedRange_; |
| 2274 | 2296 |
| 2275 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { | 2297 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { |
| (...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3958 | 3980 |
| 3959 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3981 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3960 // regions that are not draggable. (See ControlRegionView in | 3982 // regions that are not draggable. (See ControlRegionView in |
| 3961 // native_app_window_cocoa.mm). This requires the render host view to be | 3983 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3962 // draggable by default. | 3984 // draggable by default. |
| 3963 - (BOOL)mouseDownCanMoveWindow { | 3985 - (BOOL)mouseDownCanMoveWindow { |
| 3964 return YES; | 3986 return YES; |
| 3965 } | 3987 } |
| 3966 | 3988 |
| 3967 @end | 3989 @end |
| OLD | NEW |