| 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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 [background_layer_ setGeometryFlipped:YES]; | 525 [background_layer_ setGeometryFlipped:YES]; |
| 526 [background_layer_ setContentsGravity:kCAGravityTopLeft]; | 526 [background_layer_ setContentsGravity:kCAGravityTopLeft]; |
| 527 [cocoa_view_ setLayer:background_layer_]; | 527 [cocoa_view_ setLayer:background_layer_]; |
| 528 [cocoa_view_ setWantsLayer:YES]; | 528 [cocoa_view_ setWantsLayer:YES]; |
| 529 | 529 |
| 530 if (IsDelegatedRendererEnabled()) { | 530 if (IsDelegatedRendererEnabled()) { |
| 531 root_layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); | 531 root_layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); |
| 532 delegated_frame_host_.reset(new DelegatedFrameHost(this)); | 532 delegated_frame_host_.reset(new DelegatedFrameHost(this)); |
| 533 } | 533 } |
| 534 | 534 |
| 535 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); |
| 536 |
| 535 render_widget_host_->SetView(this); | 537 render_widget_host_->SetView(this); |
| 536 } | 538 } |
| 537 | 539 |
| 538 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { | 540 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
| 541 gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this); |
| 542 |
| 539 // This is being called from |cocoa_view_|'s destructor, so invalidate the | 543 // This is being called from |cocoa_view_|'s destructor, so invalidate the |
| 540 // pointer. | 544 // pointer. |
| 541 cocoa_view_ = nil; | 545 cocoa_view_ = nil; |
| 542 | 546 |
| 543 UnlockMouse(); | 547 UnlockMouse(); |
| 544 | 548 |
| 545 // Make sure that the layer doesn't reach into the now-invalid object. | 549 // Make sure that the layer doesn't reach into the now-invalid object. |
| 546 DestroyCompositedIOSurfaceAndLayer(); | 550 DestroyCompositedIOSurfaceAndLayer(); |
| 547 DestroySoftwareLayer(); | 551 DestroySoftwareLayer(); |
| 548 | 552 |
| (...skipping 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2299 void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame(bool succeeded) { | 2303 void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame(bool succeeded) { |
| 2300 if (!render_widget_host_) | 2304 if (!render_widget_host_) |
| 2301 return; | 2305 return; |
| 2302 | 2306 |
| 2303 SendPendingLatencyInfoToHost(); | 2307 SendPendingLatencyInfoToHost(); |
| 2304 SendPendingSwapAck(); | 2308 SendPendingSwapAck(); |
| 2305 if (!succeeded) | 2309 if (!succeeded) |
| 2306 GotAcceleratedCompositingError(); | 2310 GotAcceleratedCompositingError(); |
| 2307 } | 2311 } |
| 2308 | 2312 |
| 2313 //////////////////////////////////////////////////////////////////////////////// |
| 2314 // gfx::DisplayObserver, public: |
| 2315 |
| 2316 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) { |
| 2317 } |
| 2318 |
| 2319 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) { |
| 2320 } |
| 2321 |
| 2322 void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| 2323 const gfx::Display& display, uint32_t metrics) { |
| 2324 gfx::Screen* screen = gfx::Screen::GetScreenFor(cocoa_view_); |
| 2325 if (display.id() != screen->GetDisplayNearestWindow(cocoa_view_).id()) |
| 2326 return; |
| 2327 |
| 2328 UpdateScreenInfo(cocoa_view_); |
| 2329 } |
| 2330 |
| 2309 } // namespace content | 2331 } // namespace content |
| 2310 | 2332 |
| 2311 // RenderWidgetHostViewCocoa --------------------------------------------------- | 2333 // RenderWidgetHostViewCocoa --------------------------------------------------- |
| 2312 | 2334 |
| 2313 @implementation RenderWidgetHostViewCocoa | 2335 @implementation RenderWidgetHostViewCocoa |
| 2314 @synthesize selectedRange = selectedRange_; | 2336 @synthesize selectedRange = selectedRange_; |
| 2315 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_; | 2337 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_; |
| 2316 @synthesize markedRange = markedRange_; | 2338 @synthesize markedRange = markedRange_; |
| 2317 | 2339 |
| 2318 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { | 2340 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { |
| (...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3981 | 4003 |
| 3982 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 4004 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3983 // regions that are not draggable. (See ControlRegionView in | 4005 // regions that are not draggable. (See ControlRegionView in |
| 3984 // native_app_window_cocoa.mm). This requires the render host view to be | 4006 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3985 // draggable by default. | 4007 // draggable by default. |
| 3986 - (BOOL)mouseDownCanMoveWindow { | 4008 - (BOOL)mouseDownCanMoveWindow { |
| 3987 return YES; | 4009 return YES; |
| 3988 } | 4010 } |
| 3989 | 4011 |
| 3990 @end | 4012 @end |
| OLD | NEW |