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 @synthesize hostedView = hostedView_; |
| 14 |
| 15 - (id)initWithView:(views::View*)viewToHost { |
| 16 DCHECK(viewToHost); |
| 17 gfx::Rect bounds = viewToHost->bounds(); |
| 18 // To keep things simple, assume the origin is (0, 0) until there exists a use |
| 19 // case for something other than that. |
| 20 DCHECK(bounds.origin().IsOrigin()); |
| 21 NSRect initialFrame = NSMakeRect(0, 0, bounds.width(), bounds.height()); |
| 22 if ((self = [super initWithFrame:initialFrame])) |
| 23 hostedView_ = viewToHost; |
| 24 |
| 25 return self; |
| 26 } |
| 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 |