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 "base/logging.h" | |
8 #include "ui/gfx/canvas_paint_mac.h" | |
9 #include "ui/views/view.h" | |
10 | |
11 @implementation BridgedContentView | |
12 | |
13 - (id)initWithView:(views::View*)viewToHost { | |
14 DCHECK(viewToHost); | |
15 gfx::Rect bounds = viewToHost->bounds(); | |
16 // To keep things simple, assume the origin is (0, 0) until there exists a use | |
17 // case for something other than that. | |
18 DCHECK(bounds.origin().IsOrigin()); | |
19 NSRect initialFrame = NSMakeRect(0, 0, bounds.width(), bounds.height()); | |
20 if ((self = [super initWithFrame:initialFrame])) | |
21 hostedView_ = viewToHost; | |
22 | |
23 return self; | |
24 } | |
25 | |
26 @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.
| |
27 | |
28 - (void)clearView { | |
29 hostedView_ = NULL; | |
30 } | |
31 | |
32 // NSView implementation. | |
33 | |
34 - (void)setFrameSize:(NSSize)newSize { | |
35 [super setFrameSize:newSize]; | |
36 if (!hostedView_) | |
37 return; | |
38 | |
39 hostedView_->SetSize(gfx::Size(newSize.width, newSize.height)); | |
40 } | |
41 | |
42 - (void)drawRect:(NSRect)dirtyRect { | |
43 if (!hostedView_) | |
44 return; | |
45 | |
46 gfx::CanvasSkiaPaint canvas(dirtyRect, false /* opaque */); | |
47 hostedView_->Paint(&canvas, views::CullSet()); | |
48 } | |
49 | |
50 @end | |
OLD | NEW |