| 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 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 return; | 1803 return; |
| 1804 } | 1804 } |
| 1805 | 1805 |
| 1806 if (mouseEventWasIgnored_) { | 1806 if (mouseEventWasIgnored_) { |
| 1807 // If this is the first mouse event after a previous event that was ignored | 1807 // If this is the first mouse event after a previous event that was ignored |
| 1808 // due to the hitTest, send a mouse enter event to the host view. | 1808 // due to the hitTest, send a mouse enter event to the host view. |
| 1809 if (renderWidgetHostView_->render_widget_host_) { | 1809 if (renderWidgetHostView_->render_widget_host_) { |
| 1810 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); | 1810 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); |
| 1811 enterEvent.type = WebInputEvent::MouseMove; | 1811 enterEvent.type = WebInputEvent::MouseMove; |
| 1812 enterEvent.button = WebMouseEvent::Button::NoButton; | 1812 enterEvent.button = WebMouseEvent::Button::NoButton; |
| 1813 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER); |
| 1814 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 1813 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { | 1815 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { |
| 1814 renderWidgetHostView_->render_widget_host_->delegate() | 1816 renderWidgetHostView_->render_widget_host_->delegate() |
| 1815 ->GetInputEventRouter() | 1817 ->GetInputEventRouter() |
| 1816 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); | 1818 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent, |
| 1819 latency_info); |
| 1817 } else { | 1820 } else { |
| 1818 ui::LatencyInfo latency_info; | |
| 1819 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, | |
| 1820 0, 0); | |
| 1821 renderWidgetHostView_->ProcessMouseEvent(enterEvent, latency_info); | 1821 renderWidgetHostView_->ProcessMouseEvent(enterEvent, latency_info); |
| 1822 } | 1822 } |
| 1823 } | 1823 } |
| 1824 } | 1824 } |
| 1825 mouseEventWasIgnored_ = NO; | 1825 mouseEventWasIgnored_ = NO; |
| 1826 | 1826 |
| 1827 // Don't cancel child popups; killing them on a mouse click would prevent the | 1827 // Don't cancel child popups; killing them on a mouse click would prevent the |
| 1828 // user from positioning the insertion point in the text field spawning the | 1828 // user from positioning the insertion point in the text field spawning the |
| 1829 // popup. A click outside the text field would cause the text field to drop | 1829 // popup. A click outside the text field would cause the text field to drop |
| 1830 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel | 1830 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1841 // - (NSUInteger)characterIndexForPoint:. | 1841 // - (NSUInteger)characterIndexForPoint:. |
| 1842 // See: http://code.google.com/p/chromium/issues/detail?id=47141 | 1842 // See: http://code.google.com/p/chromium/issues/detail?id=47141 |
| 1843 // Instead of sending mouse events to the input method first, we now just | 1843 // Instead of sending mouse events to the input method first, we now just |
| 1844 // simply confirm all ongoing composition here. | 1844 // simply confirm all ongoing composition here. |
| 1845 if (type == NSLeftMouseDown || type == NSRightMouseDown || | 1845 if (type == NSLeftMouseDown || type == NSRightMouseDown || |
| 1846 type == NSOtherMouseDown) { | 1846 type == NSOtherMouseDown) { |
| 1847 [self finishComposingText]; | 1847 [self finishComposingText]; |
| 1848 } | 1848 } |
| 1849 | 1849 |
| 1850 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); | 1850 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); |
| 1851 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER); |
| 1852 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 1851 if (renderWidgetHostView_->ShouldRouteEvent(event)) { | 1853 if (renderWidgetHostView_->ShouldRouteEvent(event)) { |
| 1852 renderWidgetHostView_->render_widget_host_->delegate() | 1854 renderWidgetHostView_->render_widget_host_->delegate() |
| 1853 ->GetInputEventRouter() | 1855 ->GetInputEventRouter() |
| 1854 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); | 1856 ->RouteMouseEvent(renderWidgetHostView_.get(), &event, latency_info); |
| 1855 } else { | 1857 } else { |
| 1856 ui::LatencyInfo latency_info; | |
| 1857 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | |
| 1858 renderWidgetHostView_->ProcessMouseEvent(event, latency_info); | 1858 renderWidgetHostView_->ProcessMouseEvent(event, latency_info); |
| 1859 } | 1859 } |
| 1860 } | 1860 } |
| 1861 | 1861 |
| 1862 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 1862 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
| 1863 // |performKeyEquivalent:| is sent to all views of a window, not only down the | 1863 // |performKeyEquivalent:| is sent to all views of a window, not only down the |
| 1864 // responder chain (cf. "Handling Key Equivalents" in | 1864 // responder chain (cf. "Handling Key Equivalents" in |
| 1865 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
Overview/HandlingKeyEvents/HandlingKeyEvents.html | 1865 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
Overview/HandlingKeyEvents/HandlingKeyEvents.html |
| 1866 // ). We only want to handle key equivalents if we're first responder. | 1866 // ). We only want to handle key equivalents if we're first responder. |
| 1867 if ([[self window] firstResponder] != self) | 1867 if ([[self window] firstResponder] != self) |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2178 if ([event phase] != NSEventPhaseEnded && | 2178 if ([event phase] != NSEventPhaseEnded && |
| 2179 [event phase] != NSEventPhaseCancelled) { | 2179 [event phase] != NSEventPhaseCancelled) { |
| 2180 return; | 2180 return; |
| 2181 } | 2181 } |
| 2182 | 2182 |
| 2183 if (renderWidgetHostView_->render_widget_host_) { | 2183 if (renderWidgetHostView_->render_widget_host_) { |
| 2184 // History-swiping is not possible if the logic reaches this point. | 2184 // History-swiping is not possible if the logic reaches this point. |
| 2185 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( | 2185 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( |
| 2186 event, self); | 2186 event, self); |
| 2187 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); | 2187 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); |
| 2188 ui::LatencyInfo latency_info; | 2188 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
| 2189 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 2189 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 2190 renderWidgetHostView_->render_widget_host_-> | 2190 renderWidgetHostView_->render_widget_host_-> |
| 2191 ForwardWheelEventWithLatencyInfo(webEvent, latency_info); | 2191 ForwardWheelEventWithLatencyInfo(webEvent, latency_info); |
| 2192 } | 2192 } |
| 2193 | 2193 |
| 2194 if (endWheelMonitor_) { | 2194 if (endWheelMonitor_) { |
| 2195 [NSEvent removeMonitor:endWheelMonitor_]; | 2195 [NSEvent removeMonitor:endWheelMonitor_]; |
| 2196 endWheelMonitor_ = nil; | 2196 endWheelMonitor_ = nil; |
| 2197 } | 2197 } |
| 2198 } | 2198 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2349 handler:^(NSEvent* blockEvent) { | 2349 handler:^(NSEvent* blockEvent) { |
| 2350 [self shortCircuitScrollWheelEvent:blockEvent]; | 2350 [self shortCircuitScrollWheelEvent:blockEvent]; |
| 2351 return blockEvent; | 2351 return blockEvent; |
| 2352 }]; | 2352 }]; |
| 2353 } | 2353 } |
| 2354 | 2354 |
| 2355 // This is responsible for content scrolling! | 2355 // This is responsible for content scrolling! |
| 2356 if (renderWidgetHostView_->render_widget_host_) { | 2356 if (renderWidgetHostView_->render_widget_host_) { |
| 2357 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build(event, self); | 2357 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build(event, self); |
| 2358 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); | 2358 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); |
| 2359 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
| 2360 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 2359 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { | 2361 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { |
| 2360 renderWidgetHostView_->render_widget_host_->delegate() | 2362 renderWidgetHostView_->render_widget_host_->delegate() |
| 2361 ->GetInputEventRouter() | 2363 ->GetInputEventRouter() |
| 2362 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); | 2364 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent, |
| 2365 latency_info); |
| 2363 } else { | 2366 } else { |
| 2364 ui::LatencyInfo latency_info; | |
| 2365 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | |
| 2366 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent, latency_info); | 2367 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent, latency_info); |
| 2367 } | 2368 } |
| 2368 } | 2369 } |
| 2369 } | 2370 } |
| 2370 | 2371 |
| 2371 // Called repeatedly during a pinch gesture, with incremental change values. | 2372 // Called repeatedly during a pinch gesture, with incremental change values. |
| 2372 - (void)magnifyWithEvent:(NSEvent*)event { | 2373 - (void)magnifyWithEvent:(NSEvent*)event { |
| 2373 if (!renderWidgetHostView_->render_widget_host_) | 2374 if (!renderWidgetHostView_->render_widget_host_) |
| 2374 return; | 2375 return; |
| 2375 | 2376 |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3265 | 3266 |
| 3266 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3267 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3267 // regions that are not draggable. (See ControlRegionView in | 3268 // regions that are not draggable. (See ControlRegionView in |
| 3268 // native_app_window_cocoa.mm). This requires the render host view to be | 3269 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3269 // draggable by default. | 3270 // draggable by default. |
| 3270 - (BOOL)mouseDownCanMoveWindow { | 3271 - (BOOL)mouseDownCanMoveWindow { |
| 3271 return YES; | 3272 return YES; |
| 3272 } | 3273 } |
| 3273 | 3274 |
| 3274 @end | 3275 @end |
| OLD | NEW |