| Index: ui/views/controls/native/native_view_host_mac.mm
|
| diff --git a/ui/views/controls/native/native_view_host_mac.mm b/ui/views/controls/native/native_view_host_mac.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6d27adf94e332cf1af9bd2fd2853fea2b8e4d4ae
|
| --- /dev/null
|
| +++ b/ui/views/controls/native/native_view_host_mac.mm
|
| @@ -0,0 +1,103 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/views/controls/native/native_view_host_mac.h"
|
| +
|
| +#import <Cocoa/Cocoa.h>
|
| +
|
| +#include "base/logging.h"
|
| +#include "ui/base/cursor/cursor.h"
|
| +#include "ui/base/hit_test.h"
|
| +#include "ui/views/controls/native/native_view_host.h"
|
| +#include "ui/views/view_constants_aura.h"
|
| +#include "ui/views/widget/widget.h"
|
| +
|
| +namespace views {
|
| +
|
| +NativeViewHostMac::NativeViewHostMac(NativeViewHost* host) : host_(host) {
|
| +}
|
| +
|
| +NativeViewHostMac::~NativeViewHostMac() {
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// NativeViewHostMac, NativeViewHostWrapper implementation:
|
| +void NativeViewHostMac::AttachNativeView() {
|
| + DCHECK(host_->GetWidget()->GetNativeView());
|
| + Widget::ReparentNativeView(host_->native_view(),
|
| + host_->GetWidget()->GetNativeView());
|
| +}
|
| +
|
| +void NativeViewHostMac::NativeViewDetaching(bool destroyed) {
|
| + if (destroyed)
|
| + return;
|
| +
|
| + [host_->native_view() setHidden:YES];
|
| + Widget::ReparentNativeView(host_->native_view(), nil);
|
| +}
|
| +
|
| +void NativeViewHostMac::AddedToWidget() {
|
| + if (!host_->native_view())
|
| + return;
|
| +
|
| + [host_->native_view() setHidden:!host_->IsDrawn()];
|
| + Widget::ReparentNativeView(host_->native_view(),
|
| + host_->GetWidget()->GetNativeView());
|
| + host_->Layout();
|
| +}
|
| +
|
| +void NativeViewHostMac::RemovedFromWidget() {
|
| + if (!host_->native_view())
|
| + return;
|
| +
|
| + [host_->native_view() setHidden:YES];
|
| + Widget::ReparentNativeView(host_->native_view(), nil);
|
| +}
|
| +
|
| +void NativeViewHostMac::InstallClip(int x, int y, int w, int h) {
|
| + NOTIMPLEMENTED();
|
| +}
|
| +
|
| +bool NativeViewHostMac::HasInstalledClip() {
|
| + return false;
|
| +}
|
| +
|
| +void NativeViewHostMac::UninstallClip() {
|
| + NOTIMPLEMENTED();
|
| +}
|
| +
|
| +void NativeViewHostMac::ShowWidget(int x, int y, int w, int h) {
|
| + if (host_->fast_resize())
|
| + NOTIMPLEMENTED();
|
| +
|
| + // Coordinates will be from the bottom right of the parent view. Flip for Mac.
|
| + CGFloat parent_height = NSHeight([[host_->native_view() superview] bounds]);
|
| + [host_->native_view() setFrame:NSMakeRect(x, parent_height - y - h, w, h)];
|
| + [host_->native_view() setHidden:NO];
|
| +}
|
| +
|
| +void NativeViewHostMac::HideWidget() {
|
| + [host_->native_view() setHidden:YES];
|
| +}
|
| +
|
| +void NativeViewHostMac::SetFocus() {
|
| + [[host_->native_view() window] makeFirstResponder:host_->native_view()];
|
| +}
|
| +
|
| +gfx::NativeViewAccessible NativeViewHostMac::GetNativeViewAccessible() {
|
| + return NULL;
|
| +}
|
| +
|
| +gfx::NativeCursor NativeViewHostMac::GetCursor(int x, int y) {
|
| + NOTIMPLEMENTED();
|
| + return gfx::kNullCursor;
|
| +}
|
| +
|
| +// static
|
| +NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper(
|
| + NativeViewHost* host) {
|
| + return new NativeViewHostMac(host);
|
| +}
|
| +
|
| +} // namespace views
|
|
|