Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Unified Diff: ui/views/controls/native/native_view_host_mac.mm

Issue 489763002: MacViews: Gets a webview working in views_examples_with_content_exe Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase to master Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « ui/views/controls/native/native_view_host_mac.cc ('k') | ui/views/controls/native/native_view_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698