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