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