| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/views/controls/native/native_view_host_mac.h" |
| 6 |
| 7 #import <Cocoa/Cocoa.h> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "ui/base/cursor/cursor.h" |
| 11 #include "ui/base/hit_test.h" |
| 12 #include "ui/views/controls/native/native_view_host.h" |
| 13 #include "ui/views/view_constants_aura.h" |
| 14 #include "ui/views/widget/widget.h" |
| 15 |
| 16 namespace views { |
| 17 |
| 18 NativeViewHostMac::NativeViewHostMac(NativeViewHost* host) : host_(host) { |
| 19 } |
| 20 |
| 21 NativeViewHostMac::~NativeViewHostMac() { |
| 22 } |
| 23 |
| 24 //////////////////////////////////////////////////////////////////////////////// |
| 25 // NativeViewHostMac, NativeViewHostWrapper implementation: |
| 26 void NativeViewHostMac::AttachNativeView() { |
| 27 DCHECK(host_->GetWidget()->GetNativeView()); |
| 28 Widget::ReparentNativeView(host_->native_view(), |
| 29 host_->GetWidget()->GetNativeView()); |
| 30 } |
| 31 |
| 32 void NativeViewHostMac::NativeViewDetaching(bool destroyed) { |
| 33 if (destroyed) |
| 34 return; |
| 35 |
| 36 [host_->native_view() setHidden:YES]; |
| 37 Widget::ReparentNativeView(host_->native_view(), nil); |
| 38 } |
| 39 |
| 40 void NativeViewHostMac::AddedToWidget() { |
| 41 if (!host_->native_view()) |
| 42 return; |
| 43 |
| 44 [host_->native_view() setHidden:!host_->IsDrawn()]; |
| 45 Widget::ReparentNativeView(host_->native_view(), |
| 46 host_->GetWidget()->GetNativeView()); |
| 47 host_->Layout(); |
| 48 } |
| 49 |
| 50 void NativeViewHostMac::RemovedFromWidget() { |
| 51 if (!host_->native_view()) |
| 52 return; |
| 53 |
| 54 [host_->native_view() setHidden:YES]; |
| 55 Widget::ReparentNativeView(host_->native_view(), nil); |
| 56 } |
| 57 |
| 58 void NativeViewHostMac::InstallClip(int x, int y, int w, int h) { |
| 59 NOTIMPLEMENTED(); |
| 60 } |
| 61 |
| 62 bool NativeViewHostMac::HasInstalledClip() { |
| 63 return false; |
| 64 } |
| 65 |
| 66 void NativeViewHostMac::UninstallClip() { |
| 67 NOTIMPLEMENTED(); |
| 68 } |
| 69 |
| 70 void NativeViewHostMac::ShowWidget(int x, int y, int w, int h) { |
| 71 if (host_->fast_resize()) |
| 72 NOTIMPLEMENTED(); |
| 73 |
| 74 // Coordinates will be from the bottom right of the parent view. Flip for Mac. |
| 75 CGFloat parent_height = NSHeight([[host_->native_view() superview] bounds]); |
| 76 [host_->native_view() setFrame:NSMakeRect(x, parent_height - y - h, w, h)]; |
| 77 [host_->native_view() setHidden:NO]; |
| 78 } |
| 79 |
| 80 void NativeViewHostMac::HideWidget() { |
| 81 [host_->native_view() setHidden:YES]; |
| 82 } |
| 83 |
| 84 void NativeViewHostMac::SetFocus() { |
| 85 [[host_->native_view() window] makeFirstResponder:host_->native_view()]; |
| 86 } |
| 87 |
| 88 gfx::NativeViewAccessible NativeViewHostMac::GetNativeViewAccessible() { |
| 89 return NULL; |
| 90 } |
| 91 |
| 92 gfx::NativeCursor NativeViewHostMac::GetCursor(int x, int y) { |
| 93 NOTIMPLEMENTED(); |
| 94 return gfx::kNullCursor; |
| 95 } |
| 96 |
| 97 // static |
| 98 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( |
| 99 NativeViewHost* host) { |
| 100 return new NativeViewHostMac(host); |
| 101 } |
| 102 |
| 103 } // namespace views |
| OLD | NEW |