| 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 17 matching lines...) Expand all Loading... |
| 28 #include "base/trace_event/trace_event.h" | 28 #include "base/trace_event/trace_event.h" |
| 29 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 29 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
| 30 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" | 30 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
| 31 #import "content/browser/cocoa/system_hotkey_helper_mac.h" | 31 #import "content/browser/cocoa/system_hotkey_helper_mac.h" |
| 32 #import "content/browser/cocoa/system_hotkey_map.h" | 32 #import "content/browser/cocoa/system_hotkey_map.h" |
| 33 #include "content/browser/compositor/resize_lock.h" | 33 #include "content/browser/compositor/resize_lock.h" |
| 34 #include "content/browser/frame_host/frame_tree.h" | 34 #include "content/browser/frame_host/frame_tree.h" |
| 35 #include "content/browser/frame_host/frame_tree_node.h" | 35 #include "content/browser/frame_host/frame_tree_node.h" |
| 36 #include "content/browser/frame_host/render_frame_host_impl.h" | 36 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 37 #include "content/browser/gpu/compositor_util.h" | 37 #include "content/browser/gpu/compositor_util.h" |
| 38 #include "content/browser/renderer_host/input/mouse_wheel_rails_filter_mac.h" |
| 38 #include "content/browser/renderer_host/render_view_host_impl.h" | 39 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 39 #include "content/browser/renderer_host/render_widget_helper.h" | 40 #include "content/browser/renderer_host/render_widget_helper.h" |
| 40 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" | 41 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" |
| 41 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h
elper.h" | 42 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h
elper.h" |
| 42 #import "content/browser/renderer_host/text_input_client_mac.h" | 43 #import "content/browser/renderer_host/text_input_client_mac.h" |
| 43 #include "content/common/accessibility_messages.h" | 44 #include "content/common/accessibility_messages.h" |
| 44 #include "content/common/edit_command.h" | 45 #include "content/common/edit_command.h" |
| 45 #include "content/common/gpu/gpu_messages.h" | 46 #include "content/common/gpu/gpu_messages.h" |
| 46 #include "content/common/input_messages.h" | 47 #include "content/common/input_messages.h" |
| 47 #include "content/common/view_messages.h" | 48 #include "content/common/view_messages.h" |
| (...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 self = [super initWithFrame:NSZeroRect]; | 1734 self = [super initWithFrame:NSZeroRect]; |
| 1734 if (self) { | 1735 if (self) { |
| 1735 self.acceptsTouchEvents = YES; | 1736 self.acceptsTouchEvents = YES; |
| 1736 editCommand_helper_.reset(new RenderWidgetHostViewMacEditCommandHelper); | 1737 editCommand_helper_.reset(new RenderWidgetHostViewMacEditCommandHelper); |
| 1737 editCommand_helper_->AddEditingSelectorsToClass([self class]); | 1738 editCommand_helper_->AddEditingSelectorsToClass([self class]); |
| 1738 | 1739 |
| 1739 renderWidgetHostView_.reset(r); | 1740 renderWidgetHostView_.reset(r); |
| 1740 canBeKeyView_ = YES; | 1741 canBeKeyView_ = YES; |
| 1741 opaque_ = YES; | 1742 opaque_ = YES; |
| 1742 focusedPluginIdentifier_ = -1; | 1743 focusedPluginIdentifier_ = -1; |
| 1744 mouseWheelFilter_.reset(new content::MouseWheelRailsFilterMac); |
| 1743 | 1745 |
| 1744 // OpenGL support: | 1746 // OpenGL support: |
| 1745 if ([self respondsToSelector: | 1747 if ([self respondsToSelector: |
| 1746 @selector(setWantsBestResolutionOpenGLSurface:)]) { | 1748 @selector(setWantsBestResolutionOpenGLSurface:)]) { |
| 1747 [self setWantsBestResolutionOpenGLSurface:YES]; | 1749 [self setWantsBestResolutionOpenGLSurface:YES]; |
| 1748 } | 1750 } |
| 1749 [[NSNotificationCenter defaultCenter] | 1751 [[NSNotificationCenter defaultCenter] |
| 1750 addObserver:self | 1752 addObserver:self |
| 1751 selector:@selector(didChangeScreenParameters:) | 1753 selector:@selector(didChangeScreenParameters:) |
| 1752 name:NSApplicationDidChangeScreenParametersNotification | 1754 name:NSApplicationDidChangeScreenParametersNotification |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 if ([event phase] != NSEventPhaseEnded && | 2250 if ([event phase] != NSEventPhaseEnded && |
| 2249 [event phase] != NSEventPhaseCancelled) { | 2251 [event phase] != NSEventPhaseCancelled) { |
| 2250 return; | 2252 return; |
| 2251 } | 2253 } |
| 2252 | 2254 |
| 2253 if (renderWidgetHostView_->render_widget_host_) { | 2255 if (renderWidgetHostView_->render_widget_host_) { |
| 2254 // History-swiping is not possible if the logic reaches this point. | 2256 // History-swiping is not possible if the logic reaches this point. |
| 2255 // Allow rubber-banding in both directions. | 2257 // Allow rubber-banding in both directions. |
| 2256 bool canRubberbandLeft = true; | 2258 bool canRubberbandLeft = true; |
| 2257 bool canRubberbandRight = true; | 2259 bool canRubberbandRight = true; |
| 2258 const WebMouseWheelEvent webEvent = WebInputEventFactory::mouseWheelEvent( | 2260 WebMouseWheelEvent webEvent = WebInputEventFactory::mouseWheelEvent( |
| 2259 event, self, canRubberbandLeft, canRubberbandRight); | 2261 event, self, canRubberbandLeft, canRubberbandRight); |
| 2262 webEvent.railsMode = mouseWheelFilter_->UpdateRailsMode(webEvent); |
| 2260 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); | 2263 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); |
| 2261 } | 2264 } |
| 2262 | 2265 |
| 2263 if (endWheelMonitor_) { | 2266 if (endWheelMonitor_) { |
| 2264 [NSEvent removeMonitor:endWheelMonitor_]; | 2267 [NSEvent removeMonitor:endWheelMonitor_]; |
| 2265 endWheelMonitor_ = nil; | 2268 endWheelMonitor_ = nil; |
| 2266 } | 2269 } |
| 2267 } | 2270 } |
| 2268 | 2271 |
| 2269 - (void)beginGestureWithEvent:(NSEvent*)event { | 2272 - (void)beginGestureWithEvent:(NSEvent*)event { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2371 handler:^(NSEvent* blockEvent) { | 2374 handler:^(NSEvent* blockEvent) { |
| 2372 [self shortCircuitScrollWheelEvent:blockEvent]; | 2375 [self shortCircuitScrollWheelEvent:blockEvent]; |
| 2373 return blockEvent; | 2376 return blockEvent; |
| 2374 }]; | 2377 }]; |
| 2375 } | 2378 } |
| 2376 | 2379 |
| 2377 // This is responsible for content scrolling! | 2380 // This is responsible for content scrolling! |
| 2378 if (renderWidgetHostView_->render_widget_host_) { | 2381 if (renderWidgetHostView_->render_widget_host_) { |
| 2379 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; | 2382 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; |
| 2380 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; | 2383 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; |
| 2381 const WebMouseWheelEvent webEvent = WebInputEventFactory::mouseWheelEvent( | 2384 WebMouseWheelEvent webEvent = WebInputEventFactory::mouseWheelEvent( |
| 2382 event, self, canRubberbandLeft, canRubberbandRight); | 2385 event, self, canRubberbandLeft, canRubberbandRight); |
| 2386 webEvent.railsMode = mouseWheelFilter_->UpdateRailsMode(webEvent); |
| 2383 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); | 2387 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); |
| 2384 } | 2388 } |
| 2385 } | 2389 } |
| 2386 | 2390 |
| 2387 // Called repeatedly during a pinch gesture, with incremental change values. | 2391 // Called repeatedly during a pinch gesture, with incremental change values. |
| 2388 - (void)magnifyWithEvent:(NSEvent*)event { | 2392 - (void)magnifyWithEvent:(NSEvent*)event { |
| 2389 if (!renderWidgetHostView_->render_widget_host_) | 2393 if (!renderWidgetHostView_->render_widget_host_) |
| 2390 return; | 2394 return; |
| 2391 | 2395 |
| 2392 // If, due to nesting of multiple gestures (e.g, from multiple touch | 2396 // If, due to nesting of multiple gestures (e.g, from multiple touch |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3450 | 3454 |
| 3451 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3455 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3452 // regions that are not draggable. (See ControlRegionView in | 3456 // regions that are not draggable. (See ControlRegionView in |
| 3453 // native_app_window_cocoa.mm). This requires the render host view to be | 3457 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3454 // draggable by default. | 3458 // draggable by default. |
| 3455 - (BOOL)mouseDownCanMoveWindow { | 3459 - (BOOL)mouseDownCanMoveWindow { |
| 3456 return YES; | 3460 return YES; |
| 3457 } | 3461 } |
| 3458 | 3462 |
| 3459 @end | 3463 @end |
| OLD | NEW |