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

Unified Diff: ui/views/cocoa/bridged_content_view.mm

Issue 329743002: MacViews: Initial skeleton for implementing NativeWidgetMac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 6 years, 6 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
« no previous file with comments | « ui/views/cocoa/bridged_content_view.h ('k') | ui/views/cocoa/bridged_native_widget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_content_view.mm
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm
new file mode 100644
index 0000000000000000000000000000000000000000..bd9a511a24468e0b4901e9f184bcb5e6217e8919
--- /dev/null
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -0,0 +1,50 @@
+// 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.
+
+#import "ui/views/cocoa/bridged_content_view.h"
+
+#include "base/logging.h"
+#include "ui/gfx/canvas_paint_mac.h"
+#include "ui/views/view.h"
+
+@implementation BridgedContentView
+
+@synthesize hostedView = hostedView_;
+
+- (id)initWithView:(views::View*)viewToHost {
+ DCHECK(viewToHost);
+ gfx::Rect bounds = viewToHost->bounds();
+ // To keep things simple, assume the origin is (0, 0) until there exists a use
+ // case for something other than that.
+ DCHECK(bounds.origin().IsOrigin());
+ NSRect initialFrame = NSMakeRect(0, 0, bounds.width(), bounds.height());
+ if ((self = [super initWithFrame:initialFrame]))
+ hostedView_ = viewToHost;
+
+ return self;
+}
+
+- (void)clearView {
+ hostedView_ = NULL;
+}
+
+// NSView implementation.
+
+- (void)setFrameSize:(NSSize)newSize {
+ [super setFrameSize:newSize];
+ if (!hostedView_)
+ return;
+
+ hostedView_->SetSize(gfx::Size(newSize.width, newSize.height));
+}
+
+- (void)drawRect:(NSRect)dirtyRect {
+ if (!hostedView_)
+ return;
+
+ gfx::CanvasSkiaPaint canvas(dirtyRect, false /* opaque */);
+ hostedView_->Paint(&canvas, views::CullSet());
+}
+
+@end
« no previous file with comments | « ui/views/cocoa/bridged_content_view.h ('k') | ui/views/cocoa/bridged_native_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698