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 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 return; | 1866 return; |
1867 } | 1867 } |
1868 | 1868 |
1869 if (mouseEventWasIgnored_) { | 1869 if (mouseEventWasIgnored_) { |
1870 // If this is the first mouse event after a previous event that was ignored | 1870 // If this is the first mouse event after a previous event that was ignored |
1871 // due to the hitTest, send a mouse enter event to the host view. | 1871 // due to the hitTest, send a mouse enter event to the host view. |
1872 if (renderWidgetHostView_->render_widget_host_) { | 1872 if (renderWidgetHostView_->render_widget_host_) { |
1873 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); | 1873 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); |
1874 enterEvent.type = WebInputEvent::MouseMove; | 1874 enterEvent.type = WebInputEvent::MouseMove; |
1875 enterEvent.button = WebMouseEvent::Button::NoButton; | 1875 enterEvent.button = WebMouseEvent::Button::NoButton; |
| 1876 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER); |
| 1877 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
1876 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { | 1878 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { |
1877 renderWidgetHostView_->render_widget_host_->delegate() | 1879 renderWidgetHostView_->render_widget_host_->delegate() |
1878 ->GetInputEventRouter() | 1880 ->GetInputEventRouter() |
1879 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); | 1881 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent, |
| 1882 latency_info); |
1880 } else { | 1883 } else { |
1881 ui::LatencyInfo latency_info; | |
1882 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, | |
1883 0, 0); | |
1884 renderWidgetHostView_->ProcessMouseEvent(enterEvent, latency_info); | 1884 renderWidgetHostView_->ProcessMouseEvent(enterEvent, latency_info); |
1885 } | 1885 } |
1886 } | 1886 } |
1887 } | 1887 } |
1888 mouseEventWasIgnored_ = NO; | 1888 mouseEventWasIgnored_ = NO; |
1889 | 1889 |
1890 // Don't cancel child popups; killing them on a mouse click would prevent the | 1890 // Don't cancel child popups; killing them on a mouse click would prevent the |
1891 // user from positioning the insertion point in the text field spawning the | 1891 // user from positioning the insertion point in the text field spawning the |
1892 // popup. A click outside the text field would cause the text field to drop | 1892 // popup. A click outside the text field would cause the text field to drop |
1893 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel | 1893 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel |
(...skipping 10 matching lines...) Expand all Loading... |
1904 // - (NSUInteger)characterIndexForPoint:. | 1904 // - (NSUInteger)characterIndexForPoint:. |
1905 // See: http://code.google.com/p/chromium/issues/detail?id=47141 | 1905 // See: http://code.google.com/p/chromium/issues/detail?id=47141 |
1906 // Instead of sending mouse events to the input method first, we now just | 1906 // Instead of sending mouse events to the input method first, we now just |
1907 // simply confirm all ongoing composition here. | 1907 // simply confirm all ongoing composition here. |
1908 if (type == NSLeftMouseDown || type == NSRightMouseDown || | 1908 if (type == NSLeftMouseDown || type == NSRightMouseDown || |
1909 type == NSOtherMouseDown) { | 1909 type == NSOtherMouseDown) { |
1910 [self finishComposingText]; | 1910 [self finishComposingText]; |
1911 } | 1911 } |
1912 | 1912 |
1913 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); | 1913 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); |
| 1914 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER); |
| 1915 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
1914 if (renderWidgetHostView_->ShouldRouteEvent(event)) { | 1916 if (renderWidgetHostView_->ShouldRouteEvent(event)) { |
1915 renderWidgetHostView_->render_widget_host_->delegate() | 1917 renderWidgetHostView_->render_widget_host_->delegate() |
1916 ->GetInputEventRouter() | 1918 ->GetInputEventRouter() |
1917 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); | 1919 ->RouteMouseEvent(renderWidgetHostView_.get(), &event, latency_info); |
1918 } else { | 1920 } else { |
1919 ui::LatencyInfo latency_info; | |
1920 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | |
1921 renderWidgetHostView_->ProcessMouseEvent(event, latency_info); | 1921 renderWidgetHostView_->ProcessMouseEvent(event, latency_info); |
1922 } | 1922 } |
1923 } | 1923 } |
1924 | 1924 |
1925 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 1925 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
1926 // |performKeyEquivalent:| is sent to all views of a window, not only down the | 1926 // |performKeyEquivalent:| is sent to all views of a window, not only down the |
1927 // responder chain (cf. "Handling Key Equivalents" in | 1927 // responder chain (cf. "Handling Key Equivalents" in |
1928 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
Overview/HandlingKeyEvents/HandlingKeyEvents.html | 1928 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
Overview/HandlingKeyEvents/HandlingKeyEvents.html |
1929 // ). We only want to handle key equivalents if we're first responder. | 1929 // ). We only want to handle key equivalents if we're first responder. |
1930 if ([[self window] firstResponder] != self) | 1930 if ([[self window] firstResponder] != self) |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 if ([event phase] != NSEventPhaseEnded && | 2241 if ([event phase] != NSEventPhaseEnded && |
2242 [event phase] != NSEventPhaseCancelled) { | 2242 [event phase] != NSEventPhaseCancelled) { |
2243 return; | 2243 return; |
2244 } | 2244 } |
2245 | 2245 |
2246 if (renderWidgetHostView_->render_widget_host_) { | 2246 if (renderWidgetHostView_->render_widget_host_) { |
2247 // History-swiping is not possible if the logic reaches this point. | 2247 // History-swiping is not possible if the logic reaches this point. |
2248 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( | 2248 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( |
2249 event, self); | 2249 event, self); |
2250 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); | 2250 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); |
2251 ui::LatencyInfo latency_info; | 2251 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
2252 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 2252 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
2253 renderWidgetHostView_->render_widget_host_-> | 2253 renderWidgetHostView_->render_widget_host_-> |
2254 ForwardWheelEventWithLatencyInfo(webEvent, latency_info); | 2254 ForwardWheelEventWithLatencyInfo(webEvent, latency_info); |
2255 } | 2255 } |
2256 | 2256 |
2257 if (endWheelMonitor_) { | 2257 if (endWheelMonitor_) { |
2258 [NSEvent removeMonitor:endWheelMonitor_]; | 2258 [NSEvent removeMonitor:endWheelMonitor_]; |
2259 endWheelMonitor_ = nil; | 2259 endWheelMonitor_ = nil; |
2260 } | 2260 } |
2261 } | 2261 } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2440 handler:^(NSEvent* blockEvent) { | 2440 handler:^(NSEvent* blockEvent) { |
2441 [self shortCircuitScrollWheelEvent:blockEvent]; | 2441 [self shortCircuitScrollWheelEvent:blockEvent]; |
2442 return blockEvent; | 2442 return blockEvent; |
2443 }]; | 2443 }]; |
2444 } | 2444 } |
2445 | 2445 |
2446 // This is responsible for content scrolling! | 2446 // This is responsible for content scrolling! |
2447 if (renderWidgetHostView_->render_widget_host_) { | 2447 if (renderWidgetHostView_->render_widget_host_) { |
2448 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build(event, self); | 2448 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build(event, self); |
2449 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); | 2449 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); |
| 2450 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
| 2451 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
2450 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { | 2452 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { |
2451 renderWidgetHostView_->render_widget_host_->delegate() | 2453 renderWidgetHostView_->render_widget_host_->delegate() |
2452 ->GetInputEventRouter() | 2454 ->GetInputEventRouter() |
2453 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); | 2455 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent, |
| 2456 latency_info); |
2454 } else { | 2457 } else { |
2455 ui::LatencyInfo latency_info; | |
2456 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | |
2457 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent, latency_info); | 2458 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent, latency_info); |
2458 } | 2459 } |
2459 } | 2460 } |
2460 } | 2461 } |
2461 | 2462 |
2462 // Called repeatedly during a pinch gesture, with incremental change values. | 2463 // Called repeatedly during a pinch gesture, with incremental change values. |
2463 - (void)magnifyWithEvent:(NSEvent*)event { | 2464 - (void)magnifyWithEvent:(NSEvent*)event { |
2464 if (!renderWidgetHostView_->render_widget_host_) | 2465 if (!renderWidgetHostView_->render_widget_host_) |
2465 return; | 2466 return; |
2466 | 2467 |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3362 | 3363 |
3363 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3364 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3364 // regions that are not draggable. (See ControlRegionView in | 3365 // regions that are not draggable. (See ControlRegionView in |
3365 // native_app_window_cocoa.mm). This requires the render host view to be | 3366 // native_app_window_cocoa.mm). This requires the render host view to be |
3366 // draggable by default. | 3367 // draggable by default. |
3367 - (BOOL)mouseDownCanMoveWindow { | 3368 - (BOOL)mouseDownCanMoveWindow { |
3368 return YES; | 3369 return YES; |
3369 } | 3370 } |
3370 | 3371 |
3371 @end | 3372 @end |
OLD | NEW |