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 #include "ui/views/widget/native_widget_mac.h" | 5 #include "ui/views/widget/native_widget_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
14 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" | 14 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" |
15 #import "ui/base/cocoa/window_size_constants.h" | 15 #import "ui/base/cocoa/window_size_constants.h" |
16 #include "ui/gfx/font_list.h" | 16 #include "ui/gfx/font_list.h" |
17 #import "ui/gfx/mac/coordinate_conversion.h" | 17 #import "ui/gfx/mac/coordinate_conversion.h" |
18 #import "ui/gfx/mac/nswindow_frame_controls.h" | 18 #import "ui/gfx/mac/nswindow_frame_controls.h" |
19 #include "ui/native_theme/native_theme.h" | 19 #include "ui/native_theme/native_theme.h" |
20 #include "ui/native_theme/native_theme_mac.h" | 20 #include "ui/native_theme/native_theme_mac.h" |
21 #import "ui/views/cocoa/bridged_content_view.h" | 21 #import "ui/views/cocoa/bridged_content_view.h" |
22 #import "ui/views/cocoa/bridged_native_widget.h" | 22 #import "ui/views/cocoa/bridged_native_widget.h" |
23 #import "ui/views/cocoa/drag_drop_client_mac.h" | |
23 #import "ui/views/cocoa/native_widget_mac_nswindow.h" | 24 #import "ui/views/cocoa/native_widget_mac_nswindow.h" |
24 #import "ui/views/cocoa/views_nswindow_delegate.h" | 25 #import "ui/views/cocoa/views_nswindow_delegate.h" |
25 #include "ui/views/widget/widget_delegate.h" | 26 #include "ui/views/widget/widget_delegate.h" |
26 #include "ui/views/window/native_frame_view.h" | 27 #include "ui/views/window/native_frame_view.h" |
27 | 28 |
28 // Self-owning animation delegate that starts a hide animation, then calls | 29 // Self-owning animation delegate that starts a hide animation, then calls |
29 // -[NSWindow close] when the animation ends, releasing itself. | 30 // -[NSWindow close] when the animation ends, releasing itself. |
30 @interface ViewsNSWindowCloseAnimator : NSObject<NSAnimationDelegate> { | 31 @interface ViewsNSWindowCloseAnimator : NSObject<NSAnimationDelegate> { |
31 @private | 32 @private |
32 base::scoped_nsobject<NSWindow> window_; | 33 base::scoped_nsobject<NSWindow> window_; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 } | 195 } |
195 | 196 |
196 void NativeWidgetMac::ReorderNativeViews() { | 197 void NativeWidgetMac::ReorderNativeViews() { |
197 if (bridge_) { | 198 if (bridge_) { |
198 bridge_->SetRootView(GetWidget()->GetRootView()); | 199 bridge_->SetRootView(GetWidget()->GetRootView()); |
199 bridge_->ReorderChildViews(); | 200 bridge_->ReorderChildViews(); |
200 } | 201 } |
201 } | 202 } |
202 | 203 |
203 void NativeWidgetMac::ViewRemoved(View* view) { | 204 void NativeWidgetMac::ViewRemoved(View* view) { |
204 // TODO(tapted): Something for drag and drop might be needed here in future. | 205 if (bridge_) { |
tapted
2016/06/01 01:57:01
Maybe something like
DragDropClientMac* client
spqchan
2016/06/01 19:09:29
Done.
| |
205 // See http://crbug.com/464581. A NOTIMPLEMENTED() here makes a lot of spam, | 206 DCHECK(bridge_->drag_drop_client()); |
206 // so only emit it when a drag and drop could be likely. | 207 bridge_->drag_drop_client()->drop_helper()->ResetTargetViewIfEquals(view); |
207 if (IsMouseButtonDown()) | 208 } |
208 NOTIMPLEMENTED(); | |
209 } | 209 } |
210 | 210 |
211 void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) { | 211 void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) { |
212 if (bridge_) | 212 if (bridge_) |
213 bridge_->SetNativeWindowProperty(name, value); | 213 bridge_->SetNativeWindowProperty(name, value); |
214 } | 214 } |
215 | 215 |
216 void* NativeWidgetMac::GetNativeWindowProperty(const char* name) const { | 216 void* NativeWidgetMac::GetNativeWindowProperty(const char* name) const { |
217 if (bridge_) | 217 if (bridge_) |
218 return bridge_->GetNativeWindowProperty(name); | 218 return bridge_->GetNativeWindowProperty(name); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 | 500 |
501 void NativeWidgetMac::FlashFrame(bool flash_frame) { | 501 void NativeWidgetMac::FlashFrame(bool flash_frame) { |
502 NOTIMPLEMENTED(); | 502 NOTIMPLEMENTED(); |
503 } | 503 } |
504 | 504 |
505 void NativeWidgetMac::RunShellDrag(View* view, | 505 void NativeWidgetMac::RunShellDrag(View* view, |
506 const ui::OSExchangeData& data, | 506 const ui::OSExchangeData& data, |
507 const gfx::Point& location, | 507 const gfx::Point& location, |
508 int operation, | 508 int operation, |
509 ui::DragDropTypes::DragEventSource source) { | 509 ui::DragDropTypes::DragEventSource source) { |
510 NOTIMPLEMENTED(); | 510 bridge_->drag_drop_client()->StartDragAndDrop(view, data, operation, source); |
511 } | 511 } |
512 | 512 |
513 void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { | 513 void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { |
514 // |rect| is relative to client area of the window. | 514 // |rect| is relative to client area of the window. |
515 NSWindow* window = GetNativeWindow(); | 515 NSWindow* window = GetNativeWindow(); |
516 NSRect client_rect = [window contentRectForFrameRect:[window frame]]; | 516 NSRect client_rect = [window contentRectForFrameRect:[window frame]]; |
517 NSRect target_rect = rect.ToCGRect(); | 517 NSRect target_rect = rect.ToCGRect(); |
518 | 518 |
519 // Convert to Appkit coordinate system (origin at bottom left). | 519 // Convert to Appkit coordinate system (origin at bottom left). |
520 target_rect.origin.y = | 520 target_rect.origin.y = |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; | 747 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; |
748 } | 748 } |
749 | 749 |
750 - (void)animationDidEnd:(NSAnimation*)animation { | 750 - (void)animationDidEnd:(NSAnimation*)animation { |
751 [window_ close]; | 751 [window_ close]; |
752 [animation_ setDelegate:nil]; | 752 [animation_ setDelegate:nil]; |
753 [self release]; | 753 [self release]; |
754 } | 754 } |
755 | 755 |
756 @end | 756 @end |
OLD | NEW |