| 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 <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 #import <objc/runtime.h> | 8 #import <objc/runtime.h> |
| 9 #include <OpenGL/gl.h> | 9 #include <OpenGL/gl.h> |
| 10 #include <QuartzCore/QuartzCore.h> | 10 #include <QuartzCore/QuartzCore.h> |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 // may not match the page's, so use black as the gutter color to avoid | 394 // may not match the page's, so use black as the gutter color to avoid |
| 395 // flashes of brighter colors during the transition. | 395 // flashes of brighter colors during the transition. |
| 396 if (render_widget_host_->delegate() && | 396 if (render_widget_host_->delegate() && |
| 397 render_widget_host_->delegate()->IsFullscreenForCurrentTab()) { | 397 render_widget_host_->delegate()->IsFullscreenForCurrentTab()) { |
| 398 return SK_ColorBLACK; | 398 return SK_ColorBLACK; |
| 399 } | 399 } |
| 400 return color; | 400 return color; |
| 401 } | 401 } |
| 402 | 402 |
| 403 void RenderWidgetHostViewMac::BrowserCompositorMacOnBeginFrame() { | 403 void RenderWidgetHostViewMac::BrowserCompositorMacOnBeginFrame() { |
| 404 needs_flush_input_ = false; | |
| 405 render_widget_host_->OnBeginFrame(); | |
| 406 UpdateNeedsBeginFramesInternal(); | 404 UpdateNeedsBeginFramesInternal(); |
| 407 } | 405 } |
| 408 | 406 |
| 409 //////////////////////////////////////////////////////////////////////////////// | 407 //////////////////////////////////////////////////////////////////////////////// |
| 410 // AcceleratedWidgetMacNSView, public: | 408 // AcceleratedWidgetMacNSView, public: |
| 411 | 409 |
| 412 NSView* RenderWidgetHostViewMac::AcceleratedWidgetGetNSView() const { | 410 NSView* RenderWidgetHostViewMac::AcceleratedWidgetGetNSView() const { |
| 413 return cocoa_view_; | 411 return cocoa_view_; |
| 414 } | 412 } |
| 415 | 413 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 438 | 436 |
| 439 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, | 437 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, |
| 440 bool is_guest_view_hack) | 438 bool is_guest_view_hack) |
| 441 : render_widget_host_(RenderWidgetHostImpl::From(widget)), | 439 : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
| 442 page_at_minimum_scale_(true), | 440 page_at_minimum_scale_(true), |
| 443 mouse_wheel_phase_handler_(RenderWidgetHostImpl::From(widget), this), | 441 mouse_wheel_phase_handler_(RenderWidgetHostImpl::From(widget), this), |
| 444 is_loading_(false), | 442 is_loading_(false), |
| 445 allow_pause_for_resize_or_repaint_(true), | 443 allow_pause_for_resize_or_repaint_(true), |
| 446 is_guest_view_hack_(is_guest_view_hack), | 444 is_guest_view_hack_(is_guest_view_hack), |
| 447 fullscreen_parent_host_view_(nullptr), | 445 fullscreen_parent_host_view_(nullptr), |
| 448 needs_flush_input_(false), | |
| 449 weak_factory_(this) { | 446 weak_factory_(this) { |
| 450 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 447 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
| 451 // goes away. Since we autorelease it, our caller must put | 448 // goes away. Since we autorelease it, our caller must put |
| 452 // |GetNativeView()| into the view hierarchy right after calling us. | 449 // |GetNativeView()| into the view hierarchy right after calling us. |
| 453 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 450 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
| 454 initWithRenderWidgetHostViewMac:this] autorelease]; | 451 initWithRenderWidgetHostViewMac:this] autorelease]; |
| 455 | 452 |
| 456 background_layer_.reset([[CALayer alloc] init]); | 453 background_layer_.reset([[CALayer alloc] init]); |
| 457 [cocoa_view_ setLayer:background_layer_]; | 454 [cocoa_view_ setLayer:background_layer_]; |
| 458 [cocoa_view_ setWantsLayer:YES]; | 455 [cocoa_view_ setWantsLayer:YES]; |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 [cocoa_view_ setToolTipAtMousePoint:nil]; | 1201 [cocoa_view_ setToolTipAtMousePoint:nil]; |
| 1205 tooltip_text_.clear(); | 1202 tooltip_text_.clear(); |
| 1206 } | 1203 } |
| 1207 } | 1204 } |
| 1208 | 1205 |
| 1209 void RenderWidgetHostViewMac::SetNeedsBeginFrames(bool needs_begin_frames) { | 1206 void RenderWidgetHostViewMac::SetNeedsBeginFrames(bool needs_begin_frames) { |
| 1210 needs_begin_frames_ = needs_begin_frames; | 1207 needs_begin_frames_ = needs_begin_frames; |
| 1211 UpdateNeedsBeginFramesInternal(); | 1208 UpdateNeedsBeginFramesInternal(); |
| 1212 } | 1209 } |
| 1213 | 1210 |
| 1214 void RenderWidgetHostViewMac::OnSetNeedsFlushInput() { | |
| 1215 needs_flush_input_ = true; | |
| 1216 UpdateNeedsBeginFramesInternal(); | |
| 1217 } | |
| 1218 | |
| 1219 void RenderWidgetHostViewMac::UpdateNeedsBeginFramesInternal() { | 1211 void RenderWidgetHostViewMac::UpdateNeedsBeginFramesInternal() { |
| 1220 browser_compositor_->SetNeedsBeginFrames(needs_begin_frames_ || | 1212 browser_compositor_->SetNeedsBeginFrames(needs_begin_frames_); |
| 1221 needs_flush_input_); | |
| 1222 } | 1213 } |
| 1223 | 1214 |
| 1224 void RenderWidgetHostViewMac::KillSelf() { | 1215 void RenderWidgetHostViewMac::KillSelf() { |
| 1225 if (!weak_factory_.HasWeakPtrs()) { | 1216 if (!weak_factory_.HasWeakPtrs()) { |
| 1226 [cocoa_view_ setHidden:YES]; | 1217 [cocoa_view_ setHidden:YES]; |
| 1227 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1218 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1228 FROM_HERE, base::Bind(&RenderWidgetHostViewMac::ShutdownHost, | 1219 FROM_HERE, base::Bind(&RenderWidgetHostViewMac::ShutdownHost, |
| 1229 weak_factory_.GetWeakPtr())); | 1220 weak_factory_.GetWeakPtr())); |
| 1230 } | 1221 } |
| 1231 } | 1222 } |
| (...skipping 2305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3537 | 3528 |
| 3538 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3529 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3539 // regions that are not draggable. (See ControlRegionView in | 3530 // regions that are not draggable. (See ControlRegionView in |
| 3540 // native_app_window_cocoa.mm). This requires the render host view to be | 3531 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3541 // draggable by default. | 3532 // draggable by default. |
| 3542 - (BOOL)mouseDownCanMoveWindow { | 3533 - (BOOL)mouseDownCanMoveWindow { |
| 3543 return YES; | 3534 return YES; |
| 3544 } | 3535 } |
| 3545 | 3536 |
| 3546 @end | 3537 @end |
| OLD | NEW |