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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #import "ui/views/cocoa/bridged_content_view.h" | 21 #import "ui/views/cocoa/bridged_content_view.h" |
22 #import "ui/views/cocoa/views_nswindow_delegate.h" | 22 #import "ui/views/cocoa/views_nswindow_delegate.h" |
23 #include "ui/views/widget/native_widget_mac.h" | 23 #include "ui/views/widget/native_widget_mac.h" |
24 #include "ui/views/ime/input_method_bridge.h" | 24 #include "ui/views/ime/input_method_bridge.h" |
25 #include "ui/views/ime/null_input_method.h" | 25 #include "ui/views/ime/null_input_method.h" |
26 #include "ui/views/view.h" | 26 #include "ui/views/view.h" |
27 #include "ui/views/views_delegate.h" | 27 #include "ui/views/views_delegate.h" |
28 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
29 #include "ui/views/widget/widget_aura_utils.h" | 29 #include "ui/views/widget/widget_aura_utils.h" |
30 | 30 |
| 31 // The NSView that hosts the composited CALayer drawing the UI. It fills the |
| 32 // window but is not hittable so that accessibility hit tests always go to the |
| 33 // BridgedContentView. |
| 34 @interface ViewsCompositorSuperview : NSView |
| 35 @end |
| 36 |
| 37 @implementation ViewsCompositorSuperview |
| 38 - (NSView*)hitTest:(NSPoint)aPoint { |
| 39 return nil; |
| 40 } |
| 41 @end |
| 42 |
31 namespace { | 43 namespace { |
32 | 44 |
33 int kWindowPropertiesKey; | 45 int kWindowPropertiesKey; |
34 | 46 |
35 float GetDeviceScaleFactorFromView(NSView* view) { | 47 float GetDeviceScaleFactorFromView(NSView* view) { |
36 gfx::Display display = | 48 gfx::Display display = |
37 gfx::Screen::GetScreenFor(view)->GetDisplayNearestWindow(view); | 49 gfx::Screen::GetScreenFor(view)->GetDisplayNearestWindow(view); |
38 DCHECK(display.is_valid()); | 50 DCHECK(display.is_valid()); |
39 return display.device_scale_factor(); | 51 return display.device_scale_factor(); |
40 } | 52 } |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 return; | 695 return; |
684 } | 696 } |
685 compositor_widget_->ResetNSView(); | 697 compositor_widget_->ResetNSView(); |
686 compositor_.reset(); | 698 compositor_.reset(); |
687 compositor_widget_.reset(); | 699 compositor_widget_.reset(); |
688 } | 700 } |
689 | 701 |
690 void BridgedNativeWidget::AddCompositorSuperview() { | 702 void BridgedNativeWidget::AddCompositorSuperview() { |
691 DCHECK(!compositor_superview_); | 703 DCHECK(!compositor_superview_); |
692 compositor_superview_.reset( | 704 compositor_superview_.reset( |
693 [[NSView alloc] initWithFrame:[bridged_view_ bounds]]); | 705 [[ViewsCompositorSuperview alloc] initWithFrame:[bridged_view_ bounds]]); |
694 | 706 |
695 // Size and resize automatically with |bridged_view_|. | 707 // Size and resize automatically with |bridged_view_|. |
696 [compositor_superview_ | 708 [compositor_superview_ |
697 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | 709 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
698 | 710 |
699 // Enable HiDPI backing when supported (only on 10.7+). | 711 // Enable HiDPI backing when supported (only on 10.7+). |
700 if ([compositor_superview_ respondsToSelector: | 712 if ([compositor_superview_ respondsToSelector: |
701 @selector(setWantsBestResolutionOpenGLSurface:)]) { | 713 @selector(setWantsBestResolutionOpenGLSurface:)]) { |
702 [compositor_superview_ setWantsBestResolutionOpenGLSurface:YES]; | 714 [compositor_superview_ setWantsBestResolutionOpenGLSurface:YES]; |
703 } | 715 } |
(...skipping 28 matching lines...) Expand all Loading... |
732 window_, &kWindowPropertiesKey); | 744 window_, &kWindowPropertiesKey); |
733 if (!properties) { | 745 if (!properties) { |
734 properties = [NSMutableDictionary dictionary]; | 746 properties = [NSMutableDictionary dictionary]; |
735 objc_setAssociatedObject(window_, &kWindowPropertiesKey, | 747 objc_setAssociatedObject(window_, &kWindowPropertiesKey, |
736 properties, OBJC_ASSOCIATION_RETAIN); | 748 properties, OBJC_ASSOCIATION_RETAIN); |
737 } | 749 } |
738 return properties; | 750 return properties; |
739 } | 751 } |
740 | 752 |
741 } // namespace views | 753 } // namespace views |
OLD | NEW |