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

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: rebase to master (header conflict with r276556) 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
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..8e2e5fba387f2a0991501086b8cfe6b6324538f0
--- /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
+
+- (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;
+}
+
+@synthesize hostedView = hostedView_;
Robert Sesek 2014/06/12 13:42:27 @synthesize comes after @implementation with a bla
tapted 2014/06/13 00:14:06 Done.
+
+- (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

Powered by Google App Engine
This is Rietveld 408576698