| 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_native_widget.h" | 5 #import "ui/views/cocoa/bridged_native_widget.h" |
| 6 | 6 |
| 7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 // to generate a window shadow from the composited CALayer. To get around | 877 // to generate a window shadow from the composited CALayer. To get around |
| 878 // this, let the window background remain opaque and clip the window | 878 // this, let the window background remain opaque and clip the window |
| 879 // boundary in drawRect method of BridgedContentView. See crbug.com/543671. | 879 // boundary in drawRect method of BridgedContentView. See crbug.com/543671. |
| 880 if (base::mac::IsOSYosemiteOrLater()) | 880 if (base::mac::IsOSYosemiteOrLater()) |
| 881 [window_ setBackgroundColor:[NSColor clearColor]]; | 881 [window_ setBackgroundColor:[NSColor clearColor]]; |
| 882 } | 882 } |
| 883 | 883 |
| 884 UpdateLayerProperties(); | 884 UpdateLayerProperties(); |
| 885 } | 885 } |
| 886 | 886 |
| 887 void BridgedNativeWidget::SetAssociationForView(const views::View* view, |
| 888 NSView* native_view) { |
| 889 DCHECK_EQ(0u, associated_views_.count(view)); |
| 890 [bridged_view_ addSubview:native_view]; |
| 891 associated_views_[view] = native_view; |
| 892 native_widget_mac_->GetWidget()->ReorderNativeViews(); |
| 893 } |
| 894 |
| 895 void BridgedNativeWidget::ClearAssociationForView(const views::View* view) { |
| 896 auto it = associated_views_.find(view); |
| 897 DCHECK(it != associated_views_.end()); |
| 898 [it->second removeFromSuperview]; |
| 899 associated_views_.erase(it); |
| 900 } |
| 901 |
| 902 void BridgedNativeWidget::ReorderChildViews() { |
| 903 ReorderChildNSViews(native_widget_mac_->GetWidget(), associated_views_); |
| 904 } |
| 905 |
| 887 //////////////////////////////////////////////////////////////////////////////// | 906 //////////////////////////////////////////////////////////////////////////////// |
| 888 // BridgedNativeWidget, internal::InputMethodDelegate: | 907 // BridgedNativeWidget, internal::InputMethodDelegate: |
| 889 | 908 |
| 890 ui::EventDispatchDetails BridgedNativeWidget::DispatchKeyEventPostIME( | 909 ui::EventDispatchDetails BridgedNativeWidget::DispatchKeyEventPostIME( |
| 891 ui::KeyEvent* key) { | 910 ui::KeyEvent* key) { |
| 892 DCHECK(focus_manager_); | 911 DCHECK(focus_manager_); |
| 893 native_widget_mac_->GetWidget()->OnKeyEvent(key); | 912 native_widget_mac_->GetWidget()->OnKeyEvent(key); |
| 894 if (!key->handled()) { | 913 if (!key->handled()) { |
| 895 if (!focus_manager_->OnKeyEvent(*key)) | 914 if (!focus_manager_->OnKeyEvent(*key)) |
| 896 key->StopPropagation(); | 915 key->StopPropagation(); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 [bridged_view_ setMouseDownCanMoveWindow:draggable]; | 1257 [bridged_view_ setMouseDownCanMoveWindow:draggable]; |
| 1239 // AppKit will not update its cache of mouseDownCanMoveWindow unless something | 1258 // AppKit will not update its cache of mouseDownCanMoveWindow unless something |
| 1240 // changes. Previously we tried adding an NSView and removing it, but for some | 1259 // changes. Previously we tried adding an NSView and removing it, but for some |
| 1241 // reason it required reposting the mouse-down event, and didn't always work. | 1260 // reason it required reposting the mouse-down event, and didn't always work. |
| 1242 // Calling the below seems to be an effective solution. | 1261 // Calling the below seems to be an effective solution. |
| 1243 [window_ setMovableByWindowBackground:NO]; | 1262 [window_ setMovableByWindowBackground:NO]; |
| 1244 [window_ setMovableByWindowBackground:YES]; | 1263 [window_ setMovableByWindowBackground:YES]; |
| 1245 } | 1264 } |
| 1246 | 1265 |
| 1247 } // namespace views | 1266 } // namespace views |
| OLD | NEW |