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

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 now we have stats 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..0c62df53acbce9d4bcdb49311e515f2e3eb505bb
--- /dev/null
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -0,0 +1,49 @@
+// 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 "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])) {
sky 2014/06/11 16:15:53 Why the self = check here? Can initWithFrame retur
sky 2014/06/11 16:15:53 nit: no {}
tapted 2014/06/12 09:13:12 Done.
tapted 2014/06/12 09:13:12 Yeah - this is Objective C weirdness ;). Construct
sky 2014/06/12 16:51:47 I realize this is all allowed, but shouldn't we tr
Robert Sesek 2014/06/12 17:31:37 If allocation fails, that will be caught by base::
+ hostedView_ = viewToHost;
+ }
+ return self;
+}
+
+@synthesize hostedView = hostedView_;
+
+- (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