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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 | 514 |
515 // static | 515 // static |
516 void RenderWidgetHostViewBase::GetDefaultScreenInfo( | 516 void RenderWidgetHostViewBase::GetDefaultScreenInfo( |
517 blink::WebScreenInfo* results) { | 517 blink::WebScreenInfo* results) { |
518 *results = GetWebScreenInfo(NULL); | 518 *results = GetWebScreenInfo(NULL); |
519 } | 519 } |
520 | 520 |
521 /////////////////////////////////////////////////////////////////////////////// | 521 /////////////////////////////////////////////////////////////////////////////// |
522 // RenderWidgetHostViewMac, public: | 522 // RenderWidgetHostViewMac, public: |
523 | 523 |
524 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) | 524 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, |
| 525 bool is_guest_view_hack) |
525 : render_widget_host_(RenderWidgetHostImpl::From(widget)), | 526 : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
526 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 527 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
527 can_compose_inline_(true), | 528 can_compose_inline_(true), |
528 browser_compositor_view_placeholder_( | 529 browser_compositor_view_placeholder_( |
529 new BrowserCompositorViewPlaceholderMac), | 530 new BrowserCompositorViewPlaceholderMac), |
530 is_loading_(false), | 531 is_loading_(false), |
531 allow_pause_for_resize_or_repaint_(true), | 532 allow_pause_for_resize_or_repaint_(true), |
| 533 is_guest_view_hack_(is_guest_view_hack), |
532 weak_factory_(this), | 534 weak_factory_(this), |
533 fullscreen_parent_host_view_(NULL) { | 535 fullscreen_parent_host_view_(NULL) { |
534 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 536 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
535 // goes away. Since we autorelease it, our caller must put | 537 // goes away. Since we autorelease it, our caller must put |
536 // |GetNativeView()| into the view hierarchy right after calling us. | 538 // |GetNativeView()| into the view hierarchy right after calling us. |
537 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 539 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
538 initWithRenderWidgetHostViewMac:this] autorelease]; | 540 initWithRenderWidgetHostViewMac:this] autorelease]; |
539 | 541 |
540 // Make this view host a solid white layer when there is no content ready to | 542 // Make this view host a solid white layer when there is no content ready to |
541 // draw. | 543 // draw. |
542 background_layer_.reset([[CALayer alloc] init]); | 544 background_layer_.reset([[CALayer alloc] init]); |
543 [background_layer_ | 545 [background_layer_ |
544 setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; | 546 setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; |
545 [cocoa_view_ setLayer:background_layer_]; | 547 [cocoa_view_ setLayer:background_layer_]; |
546 [cocoa_view_ setWantsLayer:YES]; | 548 [cocoa_view_ setWantsLayer:YES]; |
547 | 549 |
548 if (IsDelegatedRendererEnabled()) { | 550 if (IsDelegatedRendererEnabled()) { |
549 root_layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); | 551 root_layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); |
550 delegated_frame_host_.reset(new DelegatedFrameHost(this)); | 552 delegated_frame_host_.reset(new DelegatedFrameHost(this)); |
551 } | 553 } |
552 | 554 |
553 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); | 555 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); |
554 | 556 |
555 render_widget_host_->SetView(this); | 557 if (!is_guest_view_hack_) |
| 558 render_widget_host_->SetView(this); |
556 } | 559 } |
557 | 560 |
558 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { | 561 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
559 gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this); | 562 gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this); |
560 | 563 |
561 // This is being called from |cocoa_view_|'s destructor, so invalidate the | 564 // This is being called from |cocoa_view_|'s destructor, so invalidate the |
562 // pointer. | 565 // pointer. |
563 cocoa_view_ = nil; | 566 cocoa_view_ = nil; |
564 | 567 |
565 UnlockMouse(); | 568 UnlockMouse(); |
566 | 569 |
567 // Ensure that the browser compositor is destroyed in a safe order. | 570 // Ensure that the browser compositor is destroyed in a safe order. |
568 ShutdownBrowserCompositor(); | 571 ShutdownBrowserCompositor(); |
569 | 572 |
570 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the | 573 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the |
571 // RenderWidgetHost does we need to tell it not to hold a stale pointer to | 574 // RenderWidgetHost does we need to tell it not to hold a stale pointer to |
572 // us. | 575 // us. |
573 if (render_widget_host_) | 576 if (render_widget_host_) { |
574 render_widget_host_->SetView(NULL); | 577 // If this is a RenderWidgetHostViewGuest's platform_view_, we're not the |
| 578 // RWH's view, the RenderWidgetHostViewGuest is. So don't reset the RWH's |
| 579 // view, the RenderWidgetHostViewGuest will do it. |
| 580 if (!is_guest_view_hack_) |
| 581 render_widget_host_->SetView(NULL); |
| 582 } |
575 } | 583 } |
576 | 584 |
577 void RenderWidgetHostViewMac::SetDelegate( | 585 void RenderWidgetHostViewMac::SetDelegate( |
578 NSObject<RenderWidgetHostViewMacDelegate>* delegate) { | 586 NSObject<RenderWidgetHostViewMacDelegate>* delegate) { |
579 [cocoa_view_ setResponderDelegate:delegate]; | 587 [cocoa_view_ setResponderDelegate:delegate]; |
580 } | 588 } |
581 | 589 |
582 void RenderWidgetHostViewMac::SetAllowPauseForResizeOrRepaint(bool allow) { | 590 void RenderWidgetHostViewMac::SetAllowPauseForResizeOrRepaint(bool allow) { |
583 allow_pause_for_resize_or_repaint_ = allow; | 591 allow_pause_for_resize_or_repaint_ = allow; |
584 } | 592 } |
(...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3317 | 3325 |
3318 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3326 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3319 // regions that are not draggable. (See ControlRegionView in | 3327 // regions that are not draggable. (See ControlRegionView in |
3320 // native_app_window_cocoa.mm). This requires the render host view to be | 3328 // native_app_window_cocoa.mm). This requires the render host view to be |
3321 // draggable by default. | 3329 // draggable by default. |
3322 - (BOOL)mouseDownCanMoveWindow { | 3330 - (BOOL)mouseDownCanMoveWindow { |
3323 return YES; | 3331 return YES; |
3324 } | 3332 } |
3325 | 3333 |
3326 @end | 3334 @end |
OLD | NEW |