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