Chromium Code Reviews| 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 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1629 // TODO(wjmaclean): Update this function if RenderWidgetHostViewMac implements | 1629 // TODO(wjmaclean): Update this function if RenderWidgetHostViewMac implements |
| 1630 // OnTouchEvent(), to match what we are doing in RenderWidgetHostViewAura. | 1630 // OnTouchEvent(), to match what we are doing in RenderWidgetHostViewAura. |
| 1631 DCHECK(WebInputEvent::isMouseEventType(event.type) || | 1631 DCHECK(WebInputEvent::isMouseEventType(event.type) || |
| 1632 event.type == WebInputEvent::MouseWheel); | 1632 event.type == WebInputEvent::MouseWheel); |
| 1633 return render_widget_host_->delegate() && | 1633 return render_widget_host_->delegate() && |
| 1634 render_widget_host_->delegate()->GetInputEventRouter() && | 1634 render_widget_host_->delegate()->GetInputEventRouter() && |
| 1635 SiteIsolationPolicy::AreCrossProcessFramesPossible(); | 1635 SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
| 1636 } | 1636 } |
| 1637 | 1637 |
| 1638 void RenderWidgetHostViewMac::ProcessMouseEvent( | 1638 void RenderWidgetHostViewMac::ProcessMouseEvent( |
| 1639 const blink::WebMouseEvent& event) { | 1639 const blink::WebMouseEvent& event, |
| 1640 render_widget_host_->ForwardMouseEvent(event); | 1640 const ui::LatencyInfo& latency) { |
| 1641 render_widget_host_->ForwardMouseEventWithLatencyInfo(event, latency); | |
| 1641 } | 1642 } |
| 1642 void RenderWidgetHostViewMac::ProcessMouseWheelEvent( | 1643 void RenderWidgetHostViewMac::ProcessMouseWheelEvent( |
| 1643 const blink::WebMouseWheelEvent& event) { | 1644 const blink::WebMouseWheelEvent& event, |
| 1644 ui::LatencyInfo latency_info; | 1645 const ui::LatencyInfo& latency) { |
| 1645 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 1646 render_widget_host_->ForwardWheelEventWithLatencyInfo(event, latency); |
| 1646 render_widget_host_->ForwardWheelEventWithLatencyInfo(event, latency_info); | |
| 1647 } | 1647 } |
| 1648 | 1648 |
| 1649 void RenderWidgetHostViewMac::ProcessTouchEvent( | 1649 void RenderWidgetHostViewMac::ProcessTouchEvent( |
| 1650 const blink::WebTouchEvent& event, | 1650 const blink::WebTouchEvent& event, |
| 1651 const ui::LatencyInfo& latency) { | 1651 const ui::LatencyInfo& latency) { |
| 1652 render_widget_host_->ForwardTouchEventWithLatencyInfo(event, latency); | 1652 render_widget_host_->ForwardTouchEventWithLatencyInfo(event, latency); |
| 1653 } | 1653 } |
| 1654 | 1654 |
| 1655 void RenderWidgetHostViewMac::ProcessGestureEvent( | 1655 void RenderWidgetHostViewMac::ProcessGestureEvent( |
| 1656 const blink::WebGestureEvent& event, | 1656 const blink::WebGestureEvent& event, |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1987 // due to the hitTest, send a mouse enter event to the host view. | 1987 // due to the hitTest, send a mouse enter event to the host view. |
| 1988 if (renderWidgetHostView_->render_widget_host_) { | 1988 if (renderWidgetHostView_->render_widget_host_) { |
| 1989 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); | 1989 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); |
| 1990 enterEvent.type = WebInputEvent::MouseMove; | 1990 enterEvent.type = WebInputEvent::MouseMove; |
| 1991 enterEvent.button = WebMouseEvent::ButtonNone; | 1991 enterEvent.button = WebMouseEvent::ButtonNone; |
| 1992 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { | 1992 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { |
| 1993 renderWidgetHostView_->render_widget_host_->delegate() | 1993 renderWidgetHostView_->render_widget_host_->delegate() |
| 1994 ->GetInputEventRouter() | 1994 ->GetInputEventRouter() |
| 1995 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); | 1995 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); |
| 1996 } else { | 1996 } else { |
| 1997 renderWidgetHostView_->ProcessMouseEvent(enterEvent); | 1997 ui::LatencyInfo latency_info; |
| 1998 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, | |
| 1999 0, 0); | |
|
tdresser
2016/05/20 17:24:54
Why this change? The change description states tha
sahel
2016/05/20 18:38:20
Adding WheelUI was only for mac but I explained th
tdresser
2016/05/20 18:45:53
Oops, of course, thanks.
| |
| 2000 renderWidgetHostView_->ProcessMouseEvent(enterEvent, latency_info); | |
| 1998 } | 2001 } |
| 1999 } | 2002 } |
| 2000 } | 2003 } |
| 2001 mouseEventWasIgnored_ = NO; | 2004 mouseEventWasIgnored_ = NO; |
| 2002 | 2005 |
| 2003 // Don't cancel child popups; killing them on a mouse click would prevent the | 2006 // Don't cancel child popups; killing them on a mouse click would prevent the |
| 2004 // user from positioning the insertion point in the text field spawning the | 2007 // user from positioning the insertion point in the text field spawning the |
| 2005 // popup. A click outside the text field would cause the text field to drop | 2008 // popup. A click outside the text field would cause the text field to drop |
| 2006 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel | 2009 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel |
| 2007 // the popup anyway, so we're OK. | 2010 // the popup anyway, so we're OK. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2022 type == NSOtherMouseDown) { | 2025 type == NSOtherMouseDown) { |
| 2023 [self confirmComposition]; | 2026 [self confirmComposition]; |
| 2024 } | 2027 } |
| 2025 | 2028 |
| 2026 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); | 2029 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); |
| 2027 if (renderWidgetHostView_->ShouldRouteEvent(event)) { | 2030 if (renderWidgetHostView_->ShouldRouteEvent(event)) { |
| 2028 renderWidgetHostView_->render_widget_host_->delegate() | 2031 renderWidgetHostView_->render_widget_host_->delegate() |
| 2029 ->GetInputEventRouter() | 2032 ->GetInputEventRouter() |
| 2030 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); | 2033 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); |
| 2031 } else { | 2034 } else { |
| 2032 renderWidgetHostView_->ProcessMouseEvent(event); | 2035 ui::LatencyInfo latency_info; |
| 2036 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | |
| 2037 renderWidgetHostView_->ProcessMouseEvent(event, latency_info); | |
| 2033 } | 2038 } |
| 2034 } | 2039 } |
| 2035 | 2040 |
| 2036 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 2041 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
| 2037 // |performKeyEquivalent:| is sent to all views of a window, not only down the | 2042 // |performKeyEquivalent:| is sent to all views of a window, not only down the |
| 2038 // responder chain (cf. "Handling Key Equivalents" in | 2043 // responder chain (cf. "Handling Key Equivalents" in |
| 2039 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html | 2044 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html |
| 2040 // ). We only want to handle key equivalents if we're first responder. | 2045 // ). We only want to handle key equivalents if we're first responder. |
| 2041 if ([[self window] firstResponder] != self) | 2046 if ([[self window] firstResponder] != self) |
| 2042 return NO; | 2047 return NO; |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2534 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; | 2539 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; |
| 2535 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; | 2540 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; |
| 2536 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( | 2541 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( |
| 2537 event, self, canRubberbandLeft, canRubberbandRight); | 2542 event, self, canRubberbandLeft, canRubberbandRight); |
| 2538 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); | 2543 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); |
| 2539 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { | 2544 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { |
| 2540 renderWidgetHostView_->render_widget_host_->delegate() | 2545 renderWidgetHostView_->render_widget_host_->delegate() |
| 2541 ->GetInputEventRouter() | 2546 ->GetInputEventRouter() |
| 2542 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); | 2547 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); |
| 2543 } else { | 2548 } else { |
| 2544 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent); | 2549 ui::LatencyInfo latency_info; |
| 2550 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | |
| 2551 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent, latency_info); | |
| 2545 } | 2552 } |
| 2546 } | 2553 } |
| 2547 } | 2554 } |
| 2548 | 2555 |
| 2549 // Called repeatedly during a pinch gesture, with incremental change values. | 2556 // Called repeatedly during a pinch gesture, with incremental change values. |
| 2550 - (void)magnifyWithEvent:(NSEvent*)event { | 2557 - (void)magnifyWithEvent:(NSEvent*)event { |
| 2551 if (!renderWidgetHostView_->render_widget_host_) | 2558 if (!renderWidgetHostView_->render_widget_host_) |
| 2552 return; | 2559 return; |
| 2553 | 2560 |
| 2554 // If, due to nesting of multiple gestures (e.g, from multiple touch | 2561 // 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... | |
| 3431 | 3438 |
| 3432 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3439 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3433 // regions that are not draggable. (See ControlRegionView in | 3440 // regions that are not draggable. (See ControlRegionView in |
| 3434 // native_app_window_cocoa.mm). This requires the render host view to be | 3441 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3435 // draggable by default. | 3442 // draggable by default. |
| 3436 - (BOOL)mouseDownCanMoveWindow { | 3443 - (BOOL)mouseDownCanMoveWindow { |
| 3437 return YES; | 3444 return YES; |
| 3438 } | 3445 } |
| 3439 | 3446 |
| 3440 @end | 3447 @end |
| OLD | NEW |