Chromium Code Reviews| 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 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 #import "content/public/browser/render_widget_host_view_mac_delegate.h" | 41 #import "content/public/browser/render_widget_host_view_mac_delegate.h" |
| 42 #include "skia/ext/platform_canvas.h" | 42 #include "skia/ext/platform_canvas.h" |
| 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| 45 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact ory.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact ory.h" |
| 46 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact ory.h" | 46 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact ory.h" |
| 47 #import "third_party/mozilla/ComplexTextInputPanel.h" | 47 #import "third_party/mozilla/ComplexTextInputPanel.h" |
| 48 #include "third_party/skia/include/core/SkColor.h" | 48 #include "third_party/skia/include/core/SkColor.h" |
| 49 #import "ui/base/cocoa/fullscreen_window_manager.h" | 49 #import "ui/base/cocoa/fullscreen_window_manager.h" |
| 50 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" | 50 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
| 51 #include "ui/base/layout.h" | |
| 51 #include "ui/gfx/point.h" | 52 #include "ui/gfx/point.h" |
| 52 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 53 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 53 #include "ui/surface/io_surface_support_mac.h" | 54 #include "ui/surface/io_surface_support_mac.h" |
| 54 #include "webkit/plugins/npapi/webplugin.h" | 55 #include "webkit/plugins/npapi/webplugin.h" |
| 55 | 56 |
| 56 using content::BackingStoreMac; | 57 using content::BackingStoreMac; |
| 57 using content::NativeWebKeyboardEvent; | 58 using content::NativeWebKeyboardEvent; |
| 58 using content::RenderViewHostImpl; | 59 using content::RenderViewHostImpl; |
| 59 using content::RenderWidgetHostImpl; | 60 using content::RenderWidgetHostImpl; |
| 60 using content::RenderWidgetHostViewMac; | 61 using content::RenderWidgetHostViewMac; |
| 61 using content::RenderWidgetHostViewMacEditCommandHelper; | 62 using content::RenderWidgetHostViewMacEditCommandHelper; |
| 62 using WebKit::WebInputEvent; | 63 using WebKit::WebInputEvent; |
| 63 using WebKit::WebInputEventFactory; | 64 using WebKit::WebInputEventFactory; |
| 64 using WebKit::WebMouseEvent; | 65 using WebKit::WebMouseEvent; |
| 65 using WebKit::WebMouseWheelEvent; | 66 using WebKit::WebMouseWheelEvent; |
| 66 using WebKit::WebGestureEvent; | 67 using WebKit::WebGestureEvent; |
| 67 | 68 |
| 68 // Declare things that are part of the 10.7 SDK. | 69 // Declare things that are part of the 10.7 SDK. |
| 69 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 70 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
| 70 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | 71 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
| 71 @interface NSEvent (LionAPI) | 72 @interface NSEvent (LionAPI) |
| 72 + (id)addLocalMonitorForEventsMatchingMask:(NSEventMask)mask | 73 + (id)addLocalMonitorForEventsMatchingMask:(NSEventMask)mask |
| 73 handler:(NSEvent* (^)(NSEvent*))block; | 74 handler:(NSEvent* (^)(NSEvent*))block; |
| 74 + (void)removeMonitor:(id)eventMonitor; | 75 + (void)removeMonitor:(id)eventMonitor; |
| 75 @end | 76 @end |
| 76 | 77 |
| 77 @interface NSScreen (LionAPI) | |
| 78 - (CGFloat)backingScaleFactor; | |
| 79 @end | |
| 80 | |
| 81 @interface NSWindow (LionAPI) | 78 @interface NSWindow (LionAPI) |
| 82 - (CGFloat)backingScaleFactor; | 79 - (CGFloat)backingScaleFactor; |
| 83 @end | 80 @end |
| 84 | 81 |
| 85 @interface NSView (NSOpenGLSurfaceResolutionLionAPI) | 82 @interface NSView (NSOpenGLSurfaceResolutionLionAPI) |
| 86 - (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag; | 83 - (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag; |
| 87 @end | 84 @end |
| 88 | 85 |
| 89 static NSString* const NSWindowDidChangeBackingPropertiesNotification = | 86 static NSString* const NSWindowDidChangeBackingPropertiesNotification = |
| 90 @"NSWindowDidChangeBackingPropertiesNotification"; | 87 @"NSWindowDidChangeBackingPropertiesNotification"; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 103 static inline int ToWebKitModifiers(NSUInteger flags) { | 100 static inline int ToWebKitModifiers(NSUInteger flags) { |
| 104 int modifiers = 0; | 101 int modifiers = 0; |
| 105 if (flags & NSControlKeyMask) modifiers |= WebInputEvent::ControlKey; | 102 if (flags & NSControlKeyMask) modifiers |= WebInputEvent::ControlKey; |
| 106 if (flags & NSShiftKeyMask) modifiers |= WebInputEvent::ShiftKey; | 103 if (flags & NSShiftKeyMask) modifiers |= WebInputEvent::ShiftKey; |
| 107 if (flags & NSAlternateKeyMask) modifiers |= WebInputEvent::AltKey; | 104 if (flags & NSAlternateKeyMask) modifiers |= WebInputEvent::AltKey; |
| 108 if (flags & NSCommandKeyMask) modifiers |= WebInputEvent::MetaKey; | 105 if (flags & NSCommandKeyMask) modifiers |= WebInputEvent::MetaKey; |
| 109 return modifiers; | 106 return modifiers; |
| 110 } | 107 } |
| 111 | 108 |
| 112 static float ScaleFactor(NSView* view) { | 109 static float ScaleFactor(NSView* view) { |
| 113 if (NSWindow* window = [view window]) { | 110 return ui::GetScaleFactorScale(ui::GetScaleFactorForNativeView(view)); |
|
Nico
2012/08/02 21:26:52
doesn't GetScaleFactorForNativeView() return a sca
mazda
2012/08/02 22:42:24
GetScaleFactorForNativeView returns ScaleFactor (e
Nico
2012/08/02 22:43:16
Ah, ok. Might make sense if it's needed in more pl
| |
| 114 if ([window respondsToSelector:@selector(backingScaleFactor)]) | |
| 115 return [window backingScaleFactor]; | |
| 116 return [window userSpaceScaleFactor]; | |
| 117 } | |
| 118 if (NSScreen* screen = [NSScreen mainScreen]) { | |
| 119 if ([screen respondsToSelector:@selector(backingScaleFactor)]) | |
| 120 return [screen backingScaleFactor]; | |
| 121 return [screen userSpaceScaleFactor]; | |
| 122 } | |
| 123 return 1; | |
| 124 } | 111 } |
| 125 | 112 |
| 126 // Private methods: | 113 // Private methods: |
| 127 @interface RenderWidgetHostViewCocoa () | 114 @interface RenderWidgetHostViewCocoa () |
| 128 @property(nonatomic, assign) NSRange selectedRange; | 115 @property(nonatomic, assign) NSRange selectedRange; |
| 129 @property(nonatomic, assign) NSRange markedRange; | 116 @property(nonatomic, assign) NSRange markedRange; |
| 130 | 117 |
| 131 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; | 118 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; |
| 132 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; | 119 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; |
| 133 - (void)setRWHVDelegate:(NSObject<RenderWidgetHostViewMacDelegate>*)delegate; | 120 - (void)setRWHVDelegate:(NSObject<RenderWidgetHostViewMacDelegate>*)delegate; |
| (...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3215 if (!string) return NO; | 3202 if (!string) return NO; |
| 3216 | 3203 |
| 3217 // If the user is currently using an IME, confirm the IME input, | 3204 // If the user is currently using an IME, confirm the IME input, |
| 3218 // and then insert the text from the service, the same as TextEdit and Safari. | 3205 // and then insert the text from the service, the same as TextEdit and Safari. |
| 3219 [self confirmComposition]; | 3206 [self confirmComposition]; |
| 3220 [self insertText:string]; | 3207 [self insertText:string]; |
| 3221 return YES; | 3208 return YES; |
| 3222 } | 3209 } |
| 3223 | 3210 |
| 3224 @end | 3211 @end |
| OLD | NEW |