| 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 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 // TODO(wjmaclean): Update this function if RenderWidgetHostViewMac implements | 1651 // TODO(wjmaclean): Update this function if RenderWidgetHostViewMac implements |
| 1652 // OnTouchEvent(), to match what we are doing in RenderWidgetHostViewAura. | 1652 // OnTouchEvent(), to match what we are doing in RenderWidgetHostViewAura. |
| 1653 DCHECK(WebInputEvent::isMouseEventType(event.type) || | 1653 DCHECK(WebInputEvent::isMouseEventType(event.type) || |
| 1654 event.type == WebInputEvent::MouseWheel); | 1654 event.type == WebInputEvent::MouseWheel); |
| 1655 return render_widget_host_->delegate() && | 1655 return render_widget_host_->delegate() && |
| 1656 render_widget_host_->delegate()->GetInputEventRouter() && | 1656 render_widget_host_->delegate()->GetInputEventRouter() && |
| 1657 SiteIsolationPolicy::AreCrossProcessFramesPossible(); | 1657 SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
| 1658 } | 1658 } |
| 1659 | 1659 |
| 1660 void RenderWidgetHostViewMac::ProcessMouseEvent( | 1660 void RenderWidgetHostViewMac::ProcessMouseEvent( |
| 1661 const blink::WebMouseEvent& event) { | 1661 const blink::WebMouseEvent& event, |
| 1662 render_widget_host_->ForwardMouseEvent(event); | 1662 const ui::LatencyInfo& latency) { |
| 1663 render_widget_host_->ForwardMouseEventWithLatencyInfo(event, latency); |
| 1663 } | 1664 } |
| 1664 void RenderWidgetHostViewMac::ProcessMouseWheelEvent( | 1665 void RenderWidgetHostViewMac::ProcessMouseWheelEvent( |
| 1665 const blink::WebMouseWheelEvent& event) { | 1666 const blink::WebMouseWheelEvent& event, |
| 1666 ui::LatencyInfo latency_info; | 1667 const ui::LatencyInfo& latency) { |
| 1667 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 1668 render_widget_host_->ForwardWheelEventWithLatencyInfo(event, latency); |
| 1668 render_widget_host_->ForwardWheelEventWithLatencyInfo(event, latency_info); | |
| 1669 } | 1669 } |
| 1670 | 1670 |
| 1671 void RenderWidgetHostViewMac::ProcessTouchEvent( | 1671 void RenderWidgetHostViewMac::ProcessTouchEvent( |
| 1672 const blink::WebTouchEvent& event, | 1672 const blink::WebTouchEvent& event, |
| 1673 const ui::LatencyInfo& latency) { | 1673 const ui::LatencyInfo& latency) { |
| 1674 render_widget_host_->ForwardTouchEventWithLatencyInfo(event, latency); | 1674 render_widget_host_->ForwardTouchEventWithLatencyInfo(event, latency); |
| 1675 } | 1675 } |
| 1676 | 1676 |
| 1677 void RenderWidgetHostViewMac::ProcessGestureEvent( | 1677 void RenderWidgetHostViewMac::ProcessGestureEvent( |
| 1678 const blink::WebGestureEvent& event, | 1678 const blink::WebGestureEvent& event, |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 // due to the hitTest, send a mouse enter event to the host view. | 2009 // due to the hitTest, send a mouse enter event to the host view. |
| 2010 if (renderWidgetHostView_->render_widget_host_) { | 2010 if (renderWidgetHostView_->render_widget_host_) { |
| 2011 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); | 2011 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); |
| 2012 enterEvent.type = WebInputEvent::MouseMove; | 2012 enterEvent.type = WebInputEvent::MouseMove; |
| 2013 enterEvent.button = WebMouseEvent::ButtonNone; | 2013 enterEvent.button = WebMouseEvent::ButtonNone; |
| 2014 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { | 2014 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { |
| 2015 renderWidgetHostView_->render_widget_host_->delegate() | 2015 renderWidgetHostView_->render_widget_host_->delegate() |
| 2016 ->GetInputEventRouter() | 2016 ->GetInputEventRouter() |
| 2017 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); | 2017 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); |
| 2018 } else { | 2018 } else { |
| 2019 renderWidgetHostView_->ProcessMouseEvent(enterEvent); | 2019 ui::LatencyInfo latency_info; |
| 2020 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, |
| 2021 0, 0); |
| 2022 renderWidgetHostView_->ProcessMouseEvent(enterEvent, latency_info); |
| 2020 } | 2023 } |
| 2021 } | 2024 } |
| 2022 } | 2025 } |
| 2023 mouseEventWasIgnored_ = NO; | 2026 mouseEventWasIgnored_ = NO; |
| 2024 | 2027 |
| 2025 // Don't cancel child popups; killing them on a mouse click would prevent the | 2028 // Don't cancel child popups; killing them on a mouse click would prevent the |
| 2026 // user from positioning the insertion point in the text field spawning the | 2029 // user from positioning the insertion point in the text field spawning the |
| 2027 // popup. A click outside the text field would cause the text field to drop | 2030 // popup. A click outside the text field would cause the text field to drop |
| 2028 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel | 2031 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel |
| 2029 // the popup anyway, so we're OK. | 2032 // the popup anyway, so we're OK. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2044 type == NSOtherMouseDown) { | 2047 type == NSOtherMouseDown) { |
| 2045 [self confirmComposition]; | 2048 [self confirmComposition]; |
| 2046 } | 2049 } |
| 2047 | 2050 |
| 2048 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); | 2051 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); |
| 2049 if (renderWidgetHostView_->ShouldRouteEvent(event)) { | 2052 if (renderWidgetHostView_->ShouldRouteEvent(event)) { |
| 2050 renderWidgetHostView_->render_widget_host_->delegate() | 2053 renderWidgetHostView_->render_widget_host_->delegate() |
| 2051 ->GetInputEventRouter() | 2054 ->GetInputEventRouter() |
| 2052 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); | 2055 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); |
| 2053 } else { | 2056 } else { |
| 2054 renderWidgetHostView_->ProcessMouseEvent(event); | 2057 ui::LatencyInfo latency_info; |
| 2058 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 2059 renderWidgetHostView_->ProcessMouseEvent(event, latency_info); |
| 2055 } | 2060 } |
| 2056 } | 2061 } |
| 2057 | 2062 |
| 2058 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 2063 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
| 2059 // |performKeyEquivalent:| is sent to all views of a window, not only down the | 2064 // |performKeyEquivalent:| is sent to all views of a window, not only down the |
| 2060 // responder chain (cf. "Handling Key Equivalents" in | 2065 // responder chain (cf. "Handling Key Equivalents" in |
| 2061 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
Overview/HandlingKeyEvents/HandlingKeyEvents.html | 2066 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
Overview/HandlingKeyEvents/HandlingKeyEvents.html |
| 2062 // ). We only want to handle key equivalents if we're first responder. | 2067 // ). We only want to handle key equivalents if we're first responder. |
| 2063 if ([[self window] firstResponder] != self) | 2068 if ([[self window] firstResponder] != self) |
| 2064 return NO; | 2069 return NO; |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2559 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; | 2564 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; |
| 2560 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; | 2565 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; |
| 2561 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( | 2566 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( |
| 2562 event, self, canRubberbandLeft, canRubberbandRight); | 2567 event, self, canRubberbandLeft, canRubberbandRight); |
| 2563 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); | 2568 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); |
| 2564 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { | 2569 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { |
| 2565 renderWidgetHostView_->render_widget_host_->delegate() | 2570 renderWidgetHostView_->render_widget_host_->delegate() |
| 2566 ->GetInputEventRouter() | 2571 ->GetInputEventRouter() |
| 2567 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); | 2572 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); |
| 2568 } else { | 2573 } else { |
| 2569 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent); | 2574 ui::LatencyInfo latency_info; |
| 2575 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 2576 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent, latency_info); |
| 2570 } | 2577 } |
| 2571 } | 2578 } |
| 2572 } | 2579 } |
| 2573 | 2580 |
| 2574 // Called repeatedly during a pinch gesture, with incremental change values. | 2581 // Called repeatedly during a pinch gesture, with incremental change values. |
| 2575 - (void)magnifyWithEvent:(NSEvent*)event { | 2582 - (void)magnifyWithEvent:(NSEvent*)event { |
| 2576 if (!renderWidgetHostView_->render_widget_host_) | 2583 if (!renderWidgetHostView_->render_widget_host_) |
| 2577 return; | 2584 return; |
| 2578 | 2585 |
| 2579 // If, due to nesting of multiple gestures (e.g, from multiple touch | 2586 // If, due to nesting of multiple gestures (e.g, from multiple touch |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3456 | 3463 |
| 3457 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3464 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3458 // regions that are not draggable. (See ControlRegionView in | 3465 // regions that are not draggable. (See ControlRegionView in |
| 3459 // native_app_window_cocoa.mm). This requires the render host view to be | 3466 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3460 // draggable by default. | 3467 // draggable by default. |
| 3461 - (BOOL)mouseDownCanMoveWindow { | 3468 - (BOOL)mouseDownCanMoveWindow { |
| 3462 return YES; | 3469 return YES; |
| 3463 } | 3470 } |
| 3464 | 3471 |
| 3465 @end | 3472 @end |
| OLD | NEW |