| 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 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 render_widget_host_->GetRoutingID(), compositor_frame_sink_id, | 408 render_widget_host_->GetRoutingID(), compositor_frame_sink_id, |
| 409 is_swap_ack, resources)); | 409 is_swap_ack, resources)); |
| 410 } | 410 } |
| 411 | 411 |
| 412 void RenderWidgetHostViewMac::BrowserCompositorMacOnLostCompositorResources() { | 412 void RenderWidgetHostViewMac::BrowserCompositorMacOnLostCompositorResources() { |
| 413 render_widget_host_->ScheduleComposite(); | 413 render_widget_host_->ScheduleComposite(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 void RenderWidgetHostViewMac::BrowserCompositorMacSendBeginFrame( | 416 void RenderWidgetHostViewMac::BrowserCompositorMacSendBeginFrame( |
| 417 const cc::BeginFrameArgs& args) { | 417 const cc::BeginFrameArgs& args) { |
| 418 render_widget_host_->FlushInput(); |
| 418 render_widget_host_->Send( | 419 render_widget_host_->Send( |
| 419 new ViewMsg_BeginFrame(render_widget_host_->GetRoutingID(), args)); | 420 new ViewMsg_BeginFrame(render_widget_host_->GetRoutingID(), args)); |
| 420 } | 421 } |
| 421 | 422 |
| 422 //////////////////////////////////////////////////////////////////////////////// | 423 //////////////////////////////////////////////////////////////////////////////// |
| 423 // AcceleratedWidgetMacNSView, public: | 424 // AcceleratedWidgetMacNSView, public: |
| 424 | 425 |
| 425 NSView* RenderWidgetHostViewMac::AcceleratedWidgetGetNSView() const { | 426 NSView* RenderWidgetHostViewMac::AcceleratedWidgetGetNSView() const { |
| 426 return cocoa_view_; | 427 return cocoa_view_; |
| 427 } | 428 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 444 // RenderWidgetHostViewMac, public: | 445 // RenderWidgetHostViewMac, public: |
| 445 | 446 |
| 446 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, | 447 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, |
| 447 bool is_guest_view_hack) | 448 bool is_guest_view_hack) |
| 448 : render_widget_host_(RenderWidgetHostImpl::From(widget)), | 449 : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
| 449 page_at_minimum_scale_(true), | 450 page_at_minimum_scale_(true), |
| 450 is_loading_(false), | 451 is_loading_(false), |
| 451 allow_pause_for_resize_or_repaint_(true), | 452 allow_pause_for_resize_or_repaint_(true), |
| 452 is_guest_view_hack_(is_guest_view_hack), | 453 is_guest_view_hack_(is_guest_view_hack), |
| 453 fullscreen_parent_host_view_(nullptr), | 454 fullscreen_parent_host_view_(nullptr), |
| 455 needs_begin_frames_(false), |
| 456 needs_flush_input_(false), |
| 454 weak_factory_(this) { | 457 weak_factory_(this) { |
| 455 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 458 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
| 456 // goes away. Since we autorelease it, our caller must put | 459 // goes away. Since we autorelease it, our caller must put |
| 457 // |GetNativeView()| into the view hierarchy right after calling us. | 460 // |GetNativeView()| into the view hierarchy right after calling us. |
| 458 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 461 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
| 459 initWithRenderWidgetHostViewMac:this] autorelease]; | 462 initWithRenderWidgetHostViewMac:this] autorelease]; |
| 460 | 463 |
| 461 // Paint this view host with |background_color_| when there is no content | 464 // Paint this view host with |background_color_| when there is no content |
| 462 // ready to draw. | 465 // ready to draw. |
| 463 background_layer_.reset([[CALayer alloc] init]); | 466 background_layer_.reset([[CALayer alloc] init]); |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 if (render_widget_host_) | 1184 if (render_widget_host_) |
| 1182 render_widget_host_->ForwardMouseEvent(event); | 1185 render_widget_host_->ForwardMouseEvent(event); |
| 1183 | 1186 |
| 1184 if (event.type == WebInputEvent::MouseLeave) { | 1187 if (event.type == WebInputEvent::MouseLeave) { |
| 1185 [cocoa_view_ setToolTipAtMousePoint:nil]; | 1188 [cocoa_view_ setToolTipAtMousePoint:nil]; |
| 1186 tooltip_text_.clear(); | 1189 tooltip_text_.clear(); |
| 1187 } | 1190 } |
| 1188 } | 1191 } |
| 1189 | 1192 |
| 1190 void RenderWidgetHostViewMac::SetNeedsBeginFrames(bool needs_begin_frames) { | 1193 void RenderWidgetHostViewMac::SetNeedsBeginFrames(bool needs_begin_frames) { |
| 1191 browser_compositor_->SetNeedsBeginFrames(needs_begin_frames); | 1194 needs_begin_frames_ = needs_begin_frames; |
| 1195 UpdateNeedsBeginFramesInternal(); |
| 1196 } |
| 1197 |
| 1198 void RenderWidgetHostViewMac::OnSetNeedsFlushInput() { |
| 1199 needs_flush_input_ = true; |
| 1200 UpdateNeedsBeginFramesInternal(); |
| 1201 } |
| 1202 |
| 1203 void RenderWidgetHostViewMac::UpdateNeedsBeginFramesInternal() { |
| 1204 browser_compositor_->SetNeedsBeginFrames(needs_begin_frames_ || needs_flush_in
put_); |
| 1192 } | 1205 } |
| 1193 | 1206 |
| 1194 void RenderWidgetHostViewMac::KillSelf() { | 1207 void RenderWidgetHostViewMac::KillSelf() { |
| 1195 if (!weak_factory_.HasWeakPtrs()) { | 1208 if (!weak_factory_.HasWeakPtrs()) { |
| 1196 [cocoa_view_ setHidden:YES]; | 1209 [cocoa_view_ setHidden:YES]; |
| 1197 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1210 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1198 FROM_HERE, base::Bind(&RenderWidgetHostViewMac::ShutdownHost, | 1211 FROM_HERE, base::Bind(&RenderWidgetHostViewMac::ShutdownHost, |
| 1199 weak_factory_.GetWeakPtr())); | 1212 weak_factory_.GetWeakPtr())); |
| 1200 } | 1213 } |
| 1201 } | 1214 } |
| (...skipping 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3373 | 3386 |
| 3374 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3387 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3375 // regions that are not draggable. (See ControlRegionView in | 3388 // regions that are not draggable. (See ControlRegionView in |
| 3376 // native_app_window_cocoa.mm). This requires the render host view to be | 3389 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3377 // draggable by default. | 3390 // draggable by default. |
| 3378 - (BOOL)mouseDownCanMoveWindow { | 3391 - (BOOL)mouseDownCanMoveWindow { |
| 3379 return YES; | 3392 return YES; |
| 3380 } | 3393 } |
| 3381 | 3394 |
| 3382 @end | 3395 @end |
| OLD | NEW |