OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
6 | 6 |
7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 #include <QuartzCore/QuartzCore.h> | 8 #include <QuartzCore/QuartzCore.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 @"NSBackingPropertyOldScaleFactorKey"; | 124 @"NSBackingPropertyOldScaleFactorKey"; |
125 // Note: Apple's example code (linked from the comment above | 125 // Note: Apple's example code (linked from the comment above |
126 // -windowDidChangeBackingProperties:) uses | 126 // -windowDidChangeBackingProperties:) uses |
127 // @"NSWindowBackingPropertiesChangeOldBackingScaleFactorKey", but that always | 127 // @"NSWindowBackingPropertiesChangeOldBackingScaleFactorKey", but that always |
128 // returns an old scale of 0. @"NSBackingPropertyOldScaleFactorKey" seems to | 128 // returns an old scale of 0. @"NSBackingPropertyOldScaleFactorKey" seems to |
129 // work in practice, and it's what's used in Apple's WebKit port | 129 // work in practice, and it's what's used in Apple's WebKit port |
130 // (WebKit/mac/WebView/WebView.mm). | 130 // (WebKit/mac/WebView/WebView.mm). |
131 | 131 |
132 #endif // 10.7 | 132 #endif // 10.7 |
133 | 133 |
134 static inline int ToWebKitModifiers(NSUInteger flags) { | |
135 int modifiers = 0; | |
136 if (flags & NSControlKeyMask) modifiers |= WebInputEvent::ControlKey; | |
137 if (flags & NSShiftKeyMask) modifiers |= WebInputEvent::ShiftKey; | |
138 if (flags & NSAlternateKeyMask) modifiers |= WebInputEvent::AltKey; | |
139 if (flags & NSCommandKeyMask) modifiers |= WebInputEvent::MetaKey; | |
140 return modifiers; | |
141 } | |
142 | |
143 // This method will return YES for OS X versions 10.7.3 and later, and NO | 134 // This method will return YES for OS X versions 10.7.3 and later, and NO |
144 // otherwise. | 135 // otherwise. |
145 // Used to prevent a crash when building with the 10.7 SDK and accessing the | 136 // Used to prevent a crash when building with the 10.7 SDK and accessing the |
146 // notification below. See: http://crbug.com/260595. | 137 // notification below. See: http://crbug.com/260595. |
147 static BOOL SupportsBackingPropertiesChangedNotification() { | 138 static BOOL SupportsBackingPropertiesChangedNotification() { |
148 // windowDidChangeBackingProperties: method has been added to the | 139 // windowDidChangeBackingProperties: method has been added to the |
149 // NSWindowDelegate protocol in 10.7.3, at the same time as the | 140 // NSWindowDelegate protocol in 10.7.3, at the same time as the |
150 // NSWindowDidChangeBackingPropertiesNotification notification was added. | 141 // NSWindowDidChangeBackingPropertiesNotification notification was added. |
151 // If the protocol contains this method description, the notification should | 142 // If the protocol contains this method description, the notification should |
152 // be supported as well. | 143 // be supported as well. |
(...skipping 3776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3929 return YES; | 3920 return YES; |
3930 } | 3921 } |
3931 | 3922 |
3932 - (BOOL)isOpaque { | 3923 - (BOOL)isOpaque { |
3933 if (renderWidgetHostView_->use_core_animation_) | 3924 if (renderWidgetHostView_->use_core_animation_) |
3934 return YES; | 3925 return YES; |
3935 return [super isOpaque]; | 3926 return [super isOpaque]; |
3936 } | 3927 } |
3937 | 3928 |
3938 @end | 3929 @end |
OLD | NEW |