Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 10804031: Move more files into the content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/gfx/point.h" 51 #include "ui/gfx/point.h"
52 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 52 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
53 #include "ui/surface/io_surface_support_mac.h" 53 #include "ui/surface/io_surface_support_mac.h"
54 #include "webkit/plugins/npapi/webplugin.h" 54 #include "webkit/plugins/npapi/webplugin.h"
55 55
56 using content::BrowserThread; 56 using content::BackingStoreMac;
57 using content::NativeWebKeyboardEvent; 57 using content::NativeWebKeyboardEvent;
58 using content::RenderViewHostImpl; 58 using content::RenderViewHostImpl;
59 using content::RenderWidgetHost;
60 using content::RenderWidgetHostImpl; 59 using content::RenderWidgetHostImpl;
61 using content::RenderWidgetHostView; 60 using content::RenderWidgetHostViewMac;
61 using content::RenderWidgetHostViewMacEditCommandHelper;
62 using WebKit::WebInputEvent; 62 using WebKit::WebInputEvent;
63 using WebKit::WebInputEventFactory; 63 using WebKit::WebInputEventFactory;
64 using WebKit::WebMouseEvent; 64 using WebKit::WebMouseEvent;
65 using WebKit::WebMouseWheelEvent; 65 using WebKit::WebMouseWheelEvent;
66 using WebKit::WebGestureEvent; 66 using WebKit::WebGestureEvent;
67 67
68 // Declare things that are part of the 10.7 SDK. 68 // Declare things that are part of the 10.7 SDK.
69 #if !defined(MAC_OS_X_VERSION_10_7) || \ 69 #if !defined(MAC_OS_X_VERSION_10_7) || \
70 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 70 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
71 @interface NSEvent (LionAPI) 71 @interface NSEvent (LionAPI)
(...skipping 30 matching lines...) Expand all
102 102
103 static inline int ToWebKitModifiers(NSUInteger flags) { 103 static inline int ToWebKitModifiers(NSUInteger flags) {
104 int modifiers = 0; 104 int modifiers = 0;
105 if (flags & NSControlKeyMask) modifiers |= WebInputEvent::ControlKey; 105 if (flags & NSControlKeyMask) modifiers |= WebInputEvent::ControlKey;
106 if (flags & NSShiftKeyMask) modifiers |= WebInputEvent::ShiftKey; 106 if (flags & NSShiftKeyMask) modifiers |= WebInputEvent::ShiftKey;
107 if (flags & NSAlternateKeyMask) modifiers |= WebInputEvent::AltKey; 107 if (flags & NSAlternateKeyMask) modifiers |= WebInputEvent::AltKey;
108 if (flags & NSCommandKeyMask) modifiers |= WebInputEvent::MetaKey; 108 if (flags & NSCommandKeyMask) modifiers |= WebInputEvent::MetaKey;
109 return modifiers; 109 return modifiers;
110 } 110 }
111 111
112 float ScaleFactor(NSView* view) { 112 static float ScaleFactor(NSView* view) {
113 if (NSWindow* window = [view window]) { 113 if (NSWindow* window = [view window]) {
114 if ([window respondsToSelector:@selector(backingScaleFactor)]) 114 if ([window respondsToSelector:@selector(backingScaleFactor)])
115 return [window backingScaleFactor]; 115 return [window backingScaleFactor];
116 return [window userSpaceScaleFactor]; 116 return [window userSpaceScaleFactor];
117 } 117 }
118 if (NSScreen* screen = [NSScreen mainScreen]) { 118 if (NSScreen* screen = [NSScreen mainScreen]) {
119 if ([screen respondsToSelector:@selector(backingScaleFactor)]) 119 if ([screen respondsToSelector:@selector(backingScaleFactor)])
120 return [screen backingScaleFactor]; 120 return [screen backingScaleFactor];
121 return [screen userSpaceScaleFactor]; 121 return [screen userSpaceScaleFactor];
122 } 122 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 - (BOOL)canBecomeKeyWindow { 156 - (BOOL)canBecomeKeyWindow {
157 return YES; 157 return YES;
158 } 158 }
159 159
160 - (BOOL)canBecomeMainWindow { 160 - (BOOL)canBecomeMainWindow {
161 return YES; 161 return YES;
162 } 162 }
163 163
164 @end 164 @end
165 165
166
167 namespace { 166 namespace {
168 167
169 // Maximum number of characters we allow in a tooltip. 168 // Maximum number of characters we allow in a tooltip.
170 const size_t kMaxTooltipLength = 1024; 169 const size_t kMaxTooltipLength = 1024;
171 170
172 // Invalidation NSRect to trigger a drawRect on BuffersSwapped. 171 // Invalidation NSRect to trigger a drawRect on BuffersSwapped.
173 const NSRect kGpuSwapBuffersDirtyRect = { {0, 0}, {1, 1} }; 172 const NSRect kGpuSwapBuffersDirtyRect = { {0, 0}, {1, 1} };
174 173
175 // TODO(suzhe): Upstream this function. 174 // TODO(suzhe): Upstream this function.
176 WebKit::WebColor WebColorFromNSColor(NSColor *color) { 175 WebKit::WebColor WebColorFromNSColor(NSColor *color) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (ancestor_window && (NSWidth([enclosing_window frame]) == 254 if (ancestor_window && (NSWidth([enclosing_window frame]) ==
256 NSWidth([ancestor_window frame]))) { 255 NSWidth([ancestor_window frame]))) {
257 enclosing_window = ancestor_window; 256 enclosing_window = ancestor_window;
258 } 257 }
259 258
260 return enclosing_window; 259 return enclosing_window;
261 } 260 }
262 261
263 } // namespace 262 } // namespace
264 263
264 namespace content {
265
265 /////////////////////////////////////////////////////////////////////////////// 266 ///////////////////////////////////////////////////////////////////////////////
266 // RenderWidgetHostView, public: 267 // RenderWidgetHostView, public:
267 268
268 // static 269 // static
269 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 270 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
270 RenderWidgetHost* widget) { 271 RenderWidgetHost* widget) {
271 return new RenderWidgetHostViewMac(widget); 272 return new RenderWidgetHostViewMac(widget);
272 } 273 }
273 274
274 // static 275 // static
275 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( 276 void RenderWidgetHostViewPort::GetDefaultScreenInfo(
276 WebKit::WebScreenInfo* results) { 277 WebKit::WebScreenInfo* results) {
277 *results = WebKit::WebScreenInfoFactory::screenInfo(NULL); 278 *results = WebKit::WebScreenInfoFactory::screenInfo(NULL);
278 } 279 }
279 280
280 /////////////////////////////////////////////////////////////////////////////// 281 ///////////////////////////////////////////////////////////////////////////////
281 // RenderWidgetHostViewMac, public: 282 // RenderWidgetHostViewMac, public:
282 283
283 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) 284 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget)
284 : render_widget_host_(RenderWidgetHostImpl::From(widget)), 285 : render_widget_host_(RenderWidgetHostImpl::From(widget)),
285 about_to_validate_and_paint_(false), 286 about_to_validate_and_paint_(false),
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 [cocoa_view_ setSelectedRange:range.ToNSRange()]; 766 [cocoa_view_ setSelectedRange:range.ToNSRange()];
766 // Updaes markedRange when there is no marked text so that retrieving 767 // Updaes markedRange when there is no marked text so that retrieving
767 // markedRange immediately after calling setMarkdText: returns the current 768 // markedRange immediately after calling setMarkdText: returns the current
768 // caret position. 769 // caret position.
769 if (![cocoa_view_ hasMarkedText]) { 770 if (![cocoa_view_ hasMarkedText]) {
770 [cocoa_view_ setMarkedRange:range.ToNSRange()]; 771 [cocoa_view_ setMarkedRange:range.ToNSRange()];
771 } 772 }
772 } 773 }
773 774
774 void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) { 775 void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) {
775 content::RenderWidgetHostViewBase::SetShowingContextMenu(showing); 776 RenderWidgetHostViewBase::SetShowingContextMenu(showing);
776 777
777 // Create a fake mouse event to inform the render widget that the mouse 778 // Create a fake mouse event to inform the render widget that the mouse
778 // left or entered. 779 // left or entered.
779 NSWindow* window = [cocoa_view_ window]; 780 NSWindow* window = [cocoa_view_ window];
780 // TODO(asvitkine): If the location outside of the event stream doesn't 781 // TODO(asvitkine): If the location outside of the event stream doesn't
781 // correspond to the current event (due to delayed event processing), then 782 // correspond to the current event (due to delayed event processing), then
782 // this may result in a cursor flicker if there are later mouse move events 783 // this may result in a cursor flicker if there are later mouse move events
783 // in the pipeline. Find a way to use the mouse location from the event that 784 // in the pipeline. Find a way to use the mouse location from the event that
784 // dismissed the context menu. 785 // dismissed the context menu.
785 NSPoint location = [window mouseLocationOutsideOfEventStream]; 786 NSPoint location = [window mouseLocationOutsideOfEventStream];
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 1257
1257 void RenderWidgetHostViewMac::WindowFrameChanged() { 1258 void RenderWidgetHostViewMac::WindowFrameChanged() {
1258 if (render_widget_host_) { 1259 if (render_widget_host_) {
1259 render_widget_host_->Send(new ViewMsg_WindowFrameChanged( 1260 render_widget_host_->Send(new ViewMsg_WindowFrameChanged(
1260 render_widget_host_->GetRoutingID(), GetRootWindowBounds(), 1261 render_widget_host_->GetRoutingID(), GetRootWindowBounds(),
1261 GetViewBounds())); 1262 GetViewBounds()));
1262 } 1263 }
1263 } 1264 }
1264 1265
1265 void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) { 1266 void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) {
1266 content::RenderWidgetHostViewBase::SetBackground(background); 1267 RenderWidgetHostViewBase::SetBackground(background);
1267 if (render_widget_host_) 1268 if (render_widget_host_)
1268 render_widget_host_->Send(new ViewMsg_SetBackground( 1269 render_widget_host_->Send(new ViewMsg_SetBackground(
1269 render_widget_host_->GetRoutingID(), background)); 1270 render_widget_host_->GetRoutingID(), background));
1270 } 1271 }
1271 1272
1272 void RenderWidgetHostViewMac::OnAccessibilityNotifications( 1273 void RenderWidgetHostViewMac::OnAccessibilityNotifications(
1273 const std::vector<AccessibilityHostMsg_NotificationParams>& params) { 1274 const std::vector<AccessibilityHostMsg_NotificationParams>& params) {
1274 if (!GetBrowserAccessibilityManager()) { 1275 if (!GetBrowserAccessibilityManager()) {
1275 SetBrowserAccessibilityManager( 1276 SetBrowserAccessibilityManager(
1276 BrowserAccessibilityManager::CreateEmptyDocument( 1277 BrowserAccessibilityManager::CreateEmptyDocument(
1277 cocoa_view_, 1278 cocoa_view_,
1278 static_cast<content::AccessibilityNodeData::State>(0), 1279 static_cast<AccessibilityNodeData::State>(0),
1279 NULL)); 1280 NULL));
1280 } 1281 }
1281 GetBrowserAccessibilityManager()->OnAccessibilityNotifications(params); 1282 GetBrowserAccessibilityManager()->OnAccessibilityNotifications(params);
1282 } 1283 }
1283 1284
1284 void RenderWidgetHostViewMac::SetTextInputActive(bool active) { 1285 void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
1285 if (active) { 1286 if (active) {
1286 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) 1287 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD)
1287 EnablePasswordInput(); 1288 EnablePasswordInput();
1288 else 1289 else
1289 DisablePasswordInput(); 1290 DisablePasswordInput();
1290 } else { 1291 } else {
1291 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) 1292 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD)
1292 DisablePasswordInput(); 1293 DisablePasswordInput();
1293 } 1294 }
1294 } 1295 }
1295 1296
1297 } // namespace content
1298
1296 // RenderWidgetHostViewCocoa --------------------------------------------------- 1299 // RenderWidgetHostViewCocoa ---------------------------------------------------
1297 1300
1298 @implementation RenderWidgetHostViewCocoa 1301 @implementation RenderWidgetHostViewCocoa
1299 1302
1300 @synthesize selectedRange = selectedRange_; 1303 @synthesize selectedRange = selectedRange_;
1301 @synthesize markedRange = markedRange_; 1304 @synthesize markedRange = markedRange_;
1302 1305
1303 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { 1306 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r {
1304 self = [super initWithFrame:NSZeroRect]; 1307 self = [super initWithFrame:NSZeroRect];
1305 if (self) { 1308 if (self) {
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after
3069 if (!string) return NO; 3072 if (!string) return NO;
3070 3073
3071 // If the user is currently using an IME, confirm the IME input, 3074 // If the user is currently using an IME, confirm the IME input,
3072 // and then insert the text from the service, the same as TextEdit and Safari. 3075 // and then insert the text from the service, the same as TextEdit and Safari.
3073 [self confirmComposition]; 3076 [self confirmComposition];
3074 [self insertText:string]; 3077 [self insertText:string];
3075 return YES; 3078 return YES;
3076 } 3079 }
3077 3080
3078 @end 3081 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698