OLD | NEW |
---|---|
(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 | |
OLD | NEW |