| 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); | |
| 1878 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { | 1876 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { |
| 1879 renderWidgetHostView_->render_widget_host_->delegate() | 1877 renderWidgetHostView_->render_widget_host_->delegate() |
| 1880 ->GetInputEventRouter() | 1878 ->GetInputEventRouter() |
| 1881 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent, | 1879 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); |
| 1882 latency_info); | |
| 1883 } else { | 1880 } 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); | |
| 1916 if (renderWidgetHostView_->ShouldRouteEvent(event)) { | 1914 if (renderWidgetHostView_->ShouldRouteEvent(event)) { |
| 1917 renderWidgetHostView_->render_widget_host_->delegate() | 1915 renderWidgetHostView_->render_widget_host_->delegate() |
| 1918 ->GetInputEventRouter() | 1916 ->GetInputEventRouter() |
| 1919 ->RouteMouseEvent(renderWidgetHostView_.get(), &event, latency_info); | 1917 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); |
| 1920 } else { | 1918 } 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(ui::SourceEventType::WHEEL); | 2251 ui::LatencyInfo latency_info; |
| 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); | |
| 2452 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { | 2450 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { |
| 2453 renderWidgetHostView_->render_widget_host_->delegate() | 2451 renderWidgetHostView_->render_widget_host_->delegate() |
| 2454 ->GetInputEventRouter() | 2452 ->GetInputEventRouter() |
| 2455 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent, | 2453 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); |
| 2456 latency_info); | |
| 2457 } else { | 2454 } else { |
| 2455 ui::LatencyInfo latency_info; |
| 2456 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 2458 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent, latency_info); | 2457 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent, latency_info); |
| 2459 } | 2458 } |
| 2460 } | 2459 } |
| 2461 } | 2460 } |
| 2462 | 2461 |
| 2463 // Called repeatedly during a pinch gesture, with incremental change values. | 2462 // Called repeatedly during a pinch gesture, with incremental change values. |
| 2464 - (void)magnifyWithEvent:(NSEvent*)event { | 2463 - (void)magnifyWithEvent:(NSEvent*)event { |
| 2465 if (!renderWidgetHostView_->render_widget_host_) | 2464 if (!renderWidgetHostView_->render_widget_host_) |
| 2466 return; | 2465 return; |
| 2467 | 2466 |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3372 | 3371 |
| 3373 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3372 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3374 // regions that are not draggable. (See ControlRegionView in | 3373 // regions that are not draggable. (See ControlRegionView in |
| 3375 // native_app_window_cocoa.mm). This requires the render host view to be | 3374 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3376 // draggable by default. | 3375 // draggable by default. |
| 3377 - (BOOL)mouseDownCanMoveWindow { | 3376 - (BOOL)mouseDownCanMoveWindow { |
| 3378 return YES; | 3377 return YES; |
| 3379 } | 3378 } |
| 3380 | 3379 |
| 3381 @end | 3380 @end |
| OLD | NEW |