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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "ui/views/cocoa/bridged_content_view.h"
6
7 #include "ui/gfx/canvas_paint_mac.h"
8 #include "ui/views/view.h"
9
10 @implementation BridgedContentView
11
12 - (id)initWithView:(views::View*)viewToHost {
13 DCHECK(viewToHost);
14 gfx::Rect bounds = viewToHost->bounds();
15 // To keep things simple, assume the origin is (0, 0) until there exists a use
16 // case for something other than that.
17 DCHECK(bounds.origin().IsOrigin());
18 NSRect initialFrame = NSMakeRect(0, 0, bounds.width(), bounds.height());
19 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::
20 hostedView_ = viewToHost;
21 }
22 return self;
23 }
24
25 @synthesize hostedView = hostedView_;
26
27 - (void)clearView {
28 hostedView_ = NULL;
29 }
30
31 // NSView implementation.
32
33 - (void)setFrameSize:(NSSize)newSize {
34 [super setFrameSize:newSize];
35 if (!hostedView_)
36 return;
37
38 hostedView_->SetSize(gfx::Size(newSize.width, newSize.height));
39 }
40
41 - (void)drawRect:(NSRect)dirtyRect {
42 if (!hostedView_)
43 return;
44
45 gfx::CanvasSkiaPaint canvas(dirtyRect, false /* opaque */);
46 hostedView_->Paint(&canvas, views::CullSet());
47 }
48
49 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698