OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ui/views/cocoa/bridged_content_view.h" | 5 #import "ui/views/cocoa/bridged_content_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "ui/base/ime/text_input_client.h" | 10 #include "ui/base/ime/text_input_client.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 domCode:ui::DomCode::KEY_A | 241 domCode:ui::DomCode::KEY_A |
242 eventFlags:ui::EF_CONTROL_DOWN]; | 242 eventFlags:ui::EF_CONTROL_DOWN]; |
243 } | 243 } |
244 | 244 |
245 // NSView implementation. | 245 // NSView implementation. |
246 | 246 |
247 - (BOOL)acceptsFirstResponder { | 247 - (BOOL)acceptsFirstResponder { |
248 return YES; | 248 return YES; |
249 } | 249 } |
250 | 250 |
251 - (void)viewDidMoveToWindow { | |
252 // When this view is added to a window, AppKit calls setFrameSize before it is | |
jackhou1
2015/03/13 23:32:55
Overriding viewDidMoveToWindow is one option. I li
tapted
2015/03/18 00:06:39
Yeah I like this.
| |
253 // added to the window, so the behavior in setFrameSize is not triggered. | |
254 NSWindow* window = [self window]; | |
255 if (window) | |
256 [self setFrameSize:NSZeroSize]; | |
257 } | |
258 | |
251 - (void)setFrameSize:(NSSize)newSize { | 259 - (void)setFrameSize:(NSSize)newSize { |
260 // The size passed in here does not always use | |
261 // -[NSWindow contentRectForFrameRect]. | |
tapted
2015/03/18 00:06:39
This needs a comment like
The following ensures t
jackhou1
2015/03/18 03:44:39
Done.
| |
262 NSWindow* window = [self window]; | |
263 if (window) | |
264 newSize = [window contentRectForFrameRect:[window frame]].size; | |
265 | |
252 [super setFrameSize:newSize]; | 266 [super setFrameSize:newSize]; |
253 if (!hostedView_) | 267 if (!hostedView_) |
254 return; | 268 return; |
255 | 269 |
256 hostedView_->SetSize(gfx::Size(newSize.width, newSize.height)); | 270 hostedView_->SetSize(gfx::Size(newSize.width, newSize.height)); |
257 } | 271 } |
258 | 272 |
259 - (void)drawRect:(NSRect)dirtyRect { | 273 - (void)drawRect:(NSRect)dirtyRect { |
260 // Note that BridgedNativeWidget uses -[NSWindow setAutodisplay:NO] to | 274 // Note that BridgedNativeWidget uses -[NSWindow setAutodisplay:NO] to |
261 // suppress calls to this when the window is known to be hidden. | 275 // suppress calls to this when the window is known to be hidden. |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 } | 717 } |
704 | 718 |
705 return [super accessibilityAttributeValue:attribute]; | 719 return [super accessibilityAttributeValue:attribute]; |
706 } | 720 } |
707 | 721 |
708 - (id)accessibilityHitTest:(NSPoint)point { | 722 - (id)accessibilityHitTest:(NSPoint)point { |
709 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 723 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
710 } | 724 } |
711 | 725 |
712 @end | 726 @end |
OLD | NEW |