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 <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
10 | 10 |
(...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 } | 2232 } |
2233 | 2233 |
2234 if (endWheelMonitor_) { | 2234 if (endWheelMonitor_) { |
2235 [NSEvent removeMonitor:endWheelMonitor_]; | 2235 [NSEvent removeMonitor:endWheelMonitor_]; |
2236 endWheelMonitor_ = nil; | 2236 endWheelMonitor_ = nil; |
2237 } | 2237 } |
2238 } | 2238 } |
2239 | 2239 |
2240 - (void)beginGestureWithEvent:(NSEvent*)event { | 2240 - (void)beginGestureWithEvent:(NSEvent*)event { |
2241 [responderDelegate_ beginGestureWithEvent:event]; | 2241 [responderDelegate_ beginGestureWithEvent:event]; |
| 2242 gestureBeginEvent_.reset( |
| 2243 new WebGestureEvent(WebInputEventFactory::gestureEvent(event, self))); |
2242 } | 2244 } |
| 2245 |
2243 - (void)endGestureWithEvent:(NSEvent*)event { | 2246 - (void)endGestureWithEvent:(NSEvent*)event { |
2244 [responderDelegate_ endGestureWithEvent:event]; | 2247 [responderDelegate_ endGestureWithEvent:event]; |
| 2248 gestureBeginEvent_.reset(); |
| 2249 |
| 2250 if (!renderWidgetHostView_->render_widget_host_) |
| 2251 return; |
| 2252 |
| 2253 if (gestureBeginPinchSent_) { |
| 2254 WebGestureEvent endEvent(WebInputEventFactory::gestureEvent(event, self)); |
| 2255 endEvent.type = WebInputEvent::GesturePinchEnd; |
| 2256 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(endEvent); |
| 2257 gestureBeginPinchSent_ = NO; |
| 2258 } |
2245 } | 2259 } |
| 2260 |
2246 - (void)touchesMovedWithEvent:(NSEvent*)event { | 2261 - (void)touchesMovedWithEvent:(NSEvent*)event { |
2247 [responderDelegate_ touchesMovedWithEvent:event]; | 2262 [responderDelegate_ touchesMovedWithEvent:event]; |
2248 } | 2263 } |
| 2264 |
2249 - (void)touchesBeganWithEvent:(NSEvent*)event { | 2265 - (void)touchesBeganWithEvent:(NSEvent*)event { |
2250 [responderDelegate_ touchesBeganWithEvent:event]; | 2266 [responderDelegate_ touchesBeganWithEvent:event]; |
2251 } | 2267 } |
| 2268 |
2252 - (void)touchesCancelledWithEvent:(NSEvent*)event { | 2269 - (void)touchesCancelledWithEvent:(NSEvent*)event { |
2253 [responderDelegate_ touchesCancelledWithEvent:event]; | 2270 [responderDelegate_ touchesCancelledWithEvent:event]; |
2254 } | 2271 } |
| 2272 |
2255 - (void)touchesEndedWithEvent:(NSEvent*)event { | 2273 - (void)touchesEndedWithEvent:(NSEvent*)event { |
2256 [responderDelegate_ touchesEndedWithEvent:event]; | 2274 [responderDelegate_ touchesEndedWithEvent:event]; |
2257 } | 2275 } |
2258 | 2276 |
2259 // This is invoked only on 10.8 or newer when the user taps a word using | 2277 // This is invoked only on 10.8 or newer when the user taps a word using |
2260 // three fingers. | 2278 // three fingers. |
2261 - (void)quickLookWithEvent:(NSEvent*)event { | 2279 - (void)quickLookWithEvent:(NSEvent*)event { |
2262 NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil]; | 2280 NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil]; |
2263 TextInputClientMac::GetInstance()->GetStringAtPoint( | 2281 TextInputClientMac::GetInstance()->GetStringAtPoint( |
2264 renderWidgetHostView_->render_widget_host_, | 2282 renderWidgetHostView_->render_widget_host_, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2323 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; | 2341 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; |
2324 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; | 2342 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; |
2325 const WebMouseWheelEvent webEvent = WebInputEventFactory::mouseWheelEvent( | 2343 const WebMouseWheelEvent webEvent = WebInputEventFactory::mouseWheelEvent( |
2326 event, self, canRubberbandLeft, canRubberbandRight); | 2344 event, self, canRubberbandLeft, canRubberbandRight); |
2327 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); | 2345 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); |
2328 } | 2346 } |
2329 } | 2347 } |
2330 | 2348 |
2331 // Called repeatedly during a pinch gesture, with incremental change values. | 2349 // Called repeatedly during a pinch gesture, with incremental change values. |
2332 - (void)magnifyWithEvent:(NSEvent*)event { | 2350 - (void)magnifyWithEvent:(NSEvent*)event { |
2333 if (renderWidgetHostView_->render_widget_host_) { | 2351 if (!renderWidgetHostView_->render_widget_host_) |
2334 // Send a GesturePinchUpdate event. | 2352 return; |
2335 // Note that we don't attempt to bracket these by GesturePinchBegin/End (or | 2353 |
2336 // GestureSrollBegin/End) as is done for touchscreen. Keeping track of when | 2354 // If, due to nesting of multiple gestures (e.g, from multiple touch |
2337 // a pinch is active would take a little more work here, and we don't need | 2355 // devices), the beginning of the gesture has been lost, skip the remainder |
2338 // it for anything yet. | 2356 // of the gesture. |
2339 const WebGestureEvent& webEvent = | 2357 if (!gestureBeginEvent_) |
2340 WebInputEventFactory::gestureEvent(event, self); | 2358 return; |
2341 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(webEvent); | 2359 |
| 2360 // Send a GesturePinchBegin event if none has been sent yet. |
| 2361 if (!gestureBeginPinchSent_) { |
| 2362 WebGestureEvent beginEvent(*gestureBeginEvent_); |
| 2363 beginEvent.type = WebInputEvent::GesturePinchBegin; |
| 2364 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(beginEvent); |
| 2365 gestureBeginPinchSent_ = YES; |
2342 } | 2366 } |
| 2367 |
| 2368 // Send a GesturePinchUpdate event. |
| 2369 const WebGestureEvent& updateEvent = |
| 2370 WebInputEventFactory::gestureEvent(event, self); |
| 2371 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(updateEvent); |
2343 } | 2372 } |
2344 | 2373 |
2345 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { | 2374 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { |
2346 NSWindow* oldWindow = [self window]; | 2375 NSWindow* oldWindow = [self window]; |
2347 | 2376 |
2348 NSNotificationCenter* notificationCenter = | 2377 NSNotificationCenter* notificationCenter = |
2349 [NSNotificationCenter defaultCenter]; | 2378 [NSNotificationCenter defaultCenter]; |
2350 | 2379 |
2351 // Backing property notifications crash on 10.6 when building with the 10.7 | 2380 // Backing property notifications crash on 10.6 when building with the 10.7 |
2352 // SDK, see http://crbug.com/260595. | 2381 // SDK, see http://crbug.com/260595. |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3383 | 3412 |
3384 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3413 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3385 // regions that are not draggable. (See ControlRegionView in | 3414 // regions that are not draggable. (See ControlRegionView in |
3386 // native_app_window_cocoa.mm). This requires the render host view to be | 3415 // native_app_window_cocoa.mm). This requires the render host view to be |
3387 // draggable by default. | 3416 // draggable by default. |
3388 - (BOOL)mouseDownCanMoveWindow { | 3417 - (BOOL)mouseDownCanMoveWindow { |
3389 return YES; | 3418 return YES; |
3390 } | 3419 } |
3391 | 3420 |
3392 @end | 3421 @end |
OLD | NEW |