| 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 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| 11 #import "base/mac/sdk_forward_declarations.h" | 11 #import "base/mac/sdk_forward_declarations.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "ui/base/ime/input_method.h" | 13 #include "ui/base/ime/input_method.h" |
| 14 #include "ui/base/ime/input_method_factory.h" | 14 #include "ui/base/ime/input_method_factory.h" |
| 15 #include "ui/base/ui_base_switches_util.h" | 15 #include "ui/base/ui_base_switches_util.h" |
| 16 #include "ui/gfx/display.h" | 16 #include "ui/gfx/display.h" |
| 17 #include "ui/gfx/geometry/dip_util.h" | 17 #include "ui/gfx/geometry/dip_util.h" |
| 18 #import "ui/gfx/mac/coordinate_conversion.h" | 18 #import "ui/gfx/mac/coordinate_conversion.h" |
| 19 #import "ui/gfx/mac/nswindow_frame_controls.h" | 19 #import "ui/gfx/mac/nswindow_frame_controls.h" |
| 20 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 21 #import "ui/views/cocoa/cocoa_mouse_capture.h" | 21 #import "ui/views/cocoa/cocoa_mouse_capture.h" |
| 22 #import "ui/views/cocoa/bridged_content_view.h" | 22 #import "ui/views/cocoa/bridged_content_view.h" |
| 23 #include "ui/views/cocoa/tooltip_manager_mac.h" |
| 23 #import "ui/views/cocoa/views_nswindow_delegate.h" | 24 #import "ui/views/cocoa/views_nswindow_delegate.h" |
| 24 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h" | 25 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h" |
| 25 #include "ui/views/widget/native_widget_mac.h" | 26 #include "ui/views/widget/native_widget_mac.h" |
| 26 #include "ui/views/ime/input_method_bridge.h" | 27 #include "ui/views/ime/input_method_bridge.h" |
| 27 #include "ui/views/ime/null_input_method.h" | 28 #include "ui/views/ime/null_input_method.h" |
| 28 #include "ui/views/view.h" | 29 #include "ui/views/view.h" |
| 29 #include "ui/views/views_delegate.h" | 30 #include "ui/views/views_delegate.h" |
| 30 #include "ui/views/widget/widget.h" | 31 #include "ui/views/widget/widget.h" |
| 31 #include "ui/views/widget/widget_aura_utils.h" | 32 #include "ui/views/widget/widget_aura_utils.h" |
| 32 #include "ui/views/widget/widget_delegate.h" | 33 #include "ui/views/widget/widget_delegate.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // Read back the current frame: it will be a 1x1 context rect but the frame | 190 // Read back the current frame: it will be a 1x1 context rect but the frame |
| 190 // size also depends on the window style. | 191 // size also depends on the window style. |
| 191 NSRect frame_rect = [window_ frame]; | 192 NSRect frame_rect = [window_ frame]; |
| 192 SetBounds(gfx::Rect(gfx::Point(), | 193 SetBounds(gfx::Rect(gfx::Point(), |
| 193 gfx::Size(NSWidth(frame_rect), NSHeight(frame_rect)))); | 194 gfx::Size(NSWidth(frame_rect), NSHeight(frame_rect)))); |
| 194 } | 195 } |
| 195 | 196 |
| 196 // Widgets for UI controls (usually layered above web contents) start visible. | 197 // Widgets for UI controls (usually layered above web contents) start visible. |
| 197 if (params.type == Widget::InitParams::TYPE_CONTROL) | 198 if (params.type == Widget::InitParams::TYPE_CONTROL) |
| 198 SetVisibilityState(SHOW_INACTIVE); | 199 SetVisibilityState(SHOW_INACTIVE); |
| 200 |
| 201 // Tooltip Widgets shouldn't have their own tooltip manager, but tooltips are |
| 202 // native on Mac, so nothing should ever want one in Widget form. |
| 203 DCHECK_NE(params.type, Widget::InitParams::TYPE_TOOLTIP); |
| 204 tooltip_manager_.reset(new TooltipManagerMac(this)); |
| 199 } | 205 } |
| 200 | 206 |
| 201 void BridgedNativeWidget::SetFocusManager(FocusManager* focus_manager) { | 207 void BridgedNativeWidget::SetFocusManager(FocusManager* focus_manager) { |
| 202 if (focus_manager_ == focus_manager) | 208 if (focus_manager_ == focus_manager) |
| 203 return; | 209 return; |
| 204 | 210 |
| 205 if (focus_manager_) | 211 if (focus_manager_) |
| 206 focus_manager_->RemoveFocusChangeListener(this); | 212 focus_manager_->RemoveFocusChangeListener(this); |
| 207 | 213 |
| 208 if (focus_manager) | 214 if (focus_manager) |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 window_, &kWindowPropertiesKey); | 855 window_, &kWindowPropertiesKey); |
| 850 if (!properties) { | 856 if (!properties) { |
| 851 properties = [NSMutableDictionary dictionary]; | 857 properties = [NSMutableDictionary dictionary]; |
| 852 objc_setAssociatedObject(window_, &kWindowPropertiesKey, | 858 objc_setAssociatedObject(window_, &kWindowPropertiesKey, |
| 853 properties, OBJC_ASSOCIATION_RETAIN); | 859 properties, OBJC_ASSOCIATION_RETAIN); |
| 854 } | 860 } |
| 855 return properties; | 861 return properties; |
| 856 } | 862 } |
| 857 | 863 |
| 858 } // namespace views | 864 } // namespace views |
| OLD | NEW |