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 |
| 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]. The following ensures that the |
| 262 // contentView for a frameless window can extend over the titlebar of the new |
| 263 // window containing it, since AppKit requires a titlebar to give frameless |
| 264 // windows correct shadows and rounded corners. |
| 265 NSWindow* window = [self window]; |
| 266 if (window) |
| 267 newSize = [window contentRectForFrameRect:[window frame]].size; |
| 268 |
252 [super setFrameSize:newSize]; | 269 [super setFrameSize:newSize]; |
253 if (!hostedView_) | 270 if (!hostedView_) |
254 return; | 271 return; |
255 | 272 |
256 hostedView_->SetSize(gfx::Size(newSize.width, newSize.height)); | 273 hostedView_->SetSize(gfx::Size(newSize.width, newSize.height)); |
257 } | 274 } |
258 | 275 |
259 - (void)drawRect:(NSRect)dirtyRect { | 276 - (void)drawRect:(NSRect)dirtyRect { |
260 // Note that BridgedNativeWidget uses -[NSWindow setAutodisplay:NO] to | 277 // Note that BridgedNativeWidget uses -[NSWindow setAutodisplay:NO] to |
261 // suppress calls to this when the window is known to be hidden. | 278 // 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 } | 720 } |
704 | 721 |
705 return [super accessibilityAttributeValue:attribute]; | 722 return [super accessibilityAttributeValue:attribute]; |
706 } | 723 } |
707 | 724 |
708 - (id)accessibilityHitTest:(NSPoint)point { | 725 - (id)accessibilityHitTest:(NSPoint)point { |
709 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 726 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
710 } | 727 } |
711 | 728 |
712 @end | 729 @end |
OLD | NEW |