Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 1412923009: Route touch-events for WebViewGuest directly to guest renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments, DCHECK touch events in RWHVM::ShouldRouteEvent(). Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 10 #include <utility>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 45 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
46 #import "content/browser/renderer_host/input/synthetic_gesture_target_mac.h" 46 #import "content/browser/renderer_host/input/synthetic_gesture_target_mac.h"
47 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" 47 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h"
48 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" 48 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h"
49 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h" 49 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h"
50 #import "content/browser/renderer_host/text_input_client_mac.h" 50 #import "content/browser/renderer_host/text_input_client_mac.h"
51 #include "content/common/accessibility_messages.h" 51 #include "content/common/accessibility_messages.h"
52 #include "content/common/edit_command.h" 52 #include "content/common/edit_command.h"
53 #include "content/common/gpu/gpu_messages.h" 53 #include "content/common/gpu/gpu_messages.h"
54 #include "content/common/input_messages.h" 54 #include "content/common/input_messages.h"
55 #include "content/common/site_isolation_policy.h"
55 #include "content/common/view_messages.h" 56 #include "content/common/view_messages.h"
56 #include "content/common/webplugin_geometry.h" 57 #include "content/common/webplugin_geometry.h"
57 #include "content/public/browser/browser_context.h" 58 #include "content/public/browser/browser_context.h"
58 #include "content/public/browser/browser_plugin_guest_manager.h" 59 #include "content/public/browser/browser_plugin_guest_manager.h"
59 #include "content/public/browser/browser_thread.h" 60 #include "content/public/browser/browser_thread.h"
60 #include "content/public/browser/native_web_keyboard_event.h" 61 #include "content/public/browser/native_web_keyboard_event.h"
61 #include "content/public/browser/notification_service.h" 62 #include "content/public/browser/notification_service.h"
62 #include "content/public/browser/notification_types.h" 63 #include "content/public/browser/notification_types.h"
63 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 64 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
64 #import "content/public/browser/render_widget_host_view_mac_delegate.h" 65 #import "content/public/browser/render_widget_host_view_mac_delegate.h"
(...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 transformed_point); 1601 transformed_point);
1601 *transformed_point = gfx::ConvertPointToDIP(scale_factor, *transformed_point); 1602 *transformed_point = gfx::ConvertPointToDIP(scale_factor, *transformed_point);
1602 1603
1603 // It is possible that the renderer has not yet produced a surface, in which 1604 // It is possible that the renderer has not yet produced a surface, in which
1604 // case we return our current namespace. 1605 // case we return our current namespace.
1605 if (id.is_null()) 1606 if (id.is_null())
1606 return GetSurfaceIdNamespace(); 1607 return GetSurfaceIdNamespace();
1607 return cc::SurfaceIdAllocator::NamespaceForId(id); 1608 return cc::SurfaceIdAllocator::NamespaceForId(id);
1608 } 1609 }
1609 1610
1611 bool RenderWidgetHostViewMac::ShouldRouteEvent(
1612 const WebInputEvent& event) const {
1613 // TODO(wjmaclean): update this function if RenderWidgetHostViewMac implements
1614 // OnTouchEvent(), to match what we are doing in RenderWidgetHostViewAura.
Charlie Reis 2015/12/11 21:32:52 nit: Start with // See also RenderWidgetHostViewAu
wjmaclean 2015/12/14 14:17:40 Done.
1615 DCHECK(WebInputEvent::isMouseEventType(event.type) ||
1616 event.type == WebInputEvent::MouseWheel);
1617 return render_widget_host_->delegate() &&
1618 render_widget_host_->delegate()->GetInputEventRouter() &&
1619 SiteIsolationPolicy::AreCrossProcessFramesPossible();
1620 }
1621
1610 void RenderWidgetHostViewMac::ProcessMouseEvent( 1622 void RenderWidgetHostViewMac::ProcessMouseEvent(
1611 const blink::WebMouseEvent& event) { 1623 const blink::WebMouseEvent& event) {
1612 render_widget_host_->ForwardMouseEvent(event); 1624 render_widget_host_->ForwardMouseEvent(event);
1613 } 1625 }
1614 void RenderWidgetHostViewMac::ProcessMouseWheelEvent( 1626 void RenderWidgetHostViewMac::ProcessMouseWheelEvent(
1615 const blink::WebMouseWheelEvent& event) { 1627 const blink::WebMouseWheelEvent& event) {
1616 render_widget_host_->ForwardWheelEvent(event); 1628 render_widget_host_->ForwardWheelEvent(event);
1617 } 1629 }
1618 1630
1619 void RenderWidgetHostViewMac::TransformPointToLocalCoordSpace( 1631 void RenderWidgetHostViewMac::TransformPointToLocalCoordSpace(
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 return; 1958 return;
1947 } 1959 }
1948 1960
1949 if (mouseEventWasIgnored_) { 1961 if (mouseEventWasIgnored_) {
1950 // If this is the first mouse event after a previous event that was ignored 1962 // If this is the first mouse event after a previous event that was ignored
1951 // due to the hitTest, send a mouse enter event to the host view. 1963 // due to the hitTest, send a mouse enter event to the host view.
1952 if (renderWidgetHostView_->render_widget_host_) { 1964 if (renderWidgetHostView_->render_widget_host_) {
1953 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); 1965 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self);
1954 enterEvent.type = WebInputEvent::MouseMove; 1966 enterEvent.type = WebInputEvent::MouseMove;
1955 enterEvent.button = WebMouseEvent::ButtonNone; 1967 enterEvent.button = WebMouseEvent::ButtonNone;
1956 if (renderWidgetHostView_->render_widget_host_->delegate() && 1968 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) {
1957 renderWidgetHostView_->render_widget_host_->delegate()
1958 ->GetInputEventRouter()) {
1959 renderWidgetHostView_->render_widget_host_->delegate() 1969 renderWidgetHostView_->render_widget_host_->delegate()
1960 ->GetInputEventRouter() 1970 ->GetInputEventRouter()
1961 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); 1971 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent);
1962 } else { 1972 } else {
1963 renderWidgetHostView_->ForwardMouseEvent(enterEvent); 1973 renderWidgetHostView_->ProcessMouseEvent(enterEvent);
1964 } 1974 }
1965 } 1975 }
1966 } 1976 }
1967 mouseEventWasIgnored_ = NO; 1977 mouseEventWasIgnored_ = NO;
1968 1978
1969 // Don't cancel child popups; killing them on a mouse click would prevent the 1979 // Don't cancel child popups; killing them on a mouse click would prevent the
1970 // user from positioning the insertion point in the text field spawning the 1980 // user from positioning the insertion point in the text field spawning the
1971 // popup. A click outside the text field would cause the text field to drop 1981 // popup. A click outside the text field would cause the text field to drop
1972 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel 1982 // the focus, and then EditorClientImpl::textFieldDidEndEditing() would cancel
1973 // the popup anyway, so we're OK. 1983 // the popup anyway, so we're OK.
1974 1984
1975 NSEventType type = [theEvent type]; 1985 NSEventType type = [theEvent type];
1976 if (type == NSLeftMouseDown) 1986 if (type == NSLeftMouseDown)
1977 hasOpenMouseDown_ = YES; 1987 hasOpenMouseDown_ = YES;
1978 else if (type == NSLeftMouseUp) 1988 else if (type == NSLeftMouseUp)
1979 hasOpenMouseDown_ = NO; 1989 hasOpenMouseDown_ = NO;
1980 1990
1981 // TODO(suzhe): We should send mouse events to the input method first if it 1991 // TODO(suzhe): We should send mouse events to the input method first if it
1982 // wants to handle them. But it won't work without implementing method 1992 // wants to handle them. But it won't work without implementing method
1983 // - (NSUInteger)characterIndexForPoint:. 1993 // - (NSUInteger)characterIndexForPoint:.
1984 // See: http://code.google.com/p/chromium/issues/detail?id=47141 1994 // See: http://code.google.com/p/chromium/issues/detail?id=47141
1985 // Instead of sending mouse events to the input method first, we now just 1995 // Instead of sending mouse events to the input method first, we now just
1986 // simply confirm all ongoing composition here. 1996 // simply confirm all ongoing composition here.
1987 if (type == NSLeftMouseDown || type == NSRightMouseDown || 1997 if (type == NSLeftMouseDown || type == NSRightMouseDown ||
1988 type == NSOtherMouseDown) { 1998 type == NSOtherMouseDown) {
1989 [self confirmComposition]; 1999 [self confirmComposition];
1990 } 2000 }
1991 2001
1992 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self); 2002 WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self);
1993 if (renderWidgetHostView_->render_widget_host_->delegate() && 2003 if (renderWidgetHostView_->ShouldRouteEvent(event)) {
1994 renderWidgetHostView_->render_widget_host_->delegate()
1995 ->GetInputEventRouter()) {
1996 renderWidgetHostView_->render_widget_host_->delegate() 2004 renderWidgetHostView_->render_widget_host_->delegate()
1997 ->GetInputEventRouter() 2005 ->GetInputEventRouter()
1998 ->RouteMouseEvent(renderWidgetHostView_.get(), &event); 2006 ->RouteMouseEvent(renderWidgetHostView_.get(), &event);
1999 } else { 2007 } else {
2000 renderWidgetHostView_->ForwardMouseEvent(event); 2008 renderWidgetHostView_->ProcessMouseEvent(event);
2001 } 2009 }
2002 } 2010 }
2003 2011
2004 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { 2012 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent {
2005 // |performKeyEquivalent:| is sent to all views of a window, not only down the 2013 // |performKeyEquivalent:| is sent to all views of a window, not only down the
2006 // responder chain (cf. "Handling Key Equivalents" in 2014 // responder chain (cf. "Handling Key Equivalents" in
2007 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html 2015 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html
2008 // ). We only want to handle key equivalents if we're first responder. 2016 // ). We only want to handle key equivalents if we're first responder.
2009 if ([[self window] firstResponder] != self) 2017 if ([[self window] firstResponder] != self)
2010 return NO; 2018 return NO;
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 }]; 2502 }];
2495 } 2503 }
2496 2504
2497 // This is responsible for content scrolling! 2505 // This is responsible for content scrolling!
2498 if (renderWidgetHostView_->render_widget_host_) { 2506 if (renderWidgetHostView_->render_widget_host_) {
2499 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self]; 2507 BOOL canRubberbandLeft = [responderDelegate_ canRubberbandLeft:self];
2500 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self]; 2508 BOOL canRubberbandRight = [responderDelegate_ canRubberbandRight:self];
2501 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( 2509 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build(
2502 event, self, canRubberbandLeft, canRubberbandRight); 2510 event, self, canRubberbandLeft, canRubberbandRight);
2503 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent); 2511 webEvent.railsMode = mouseWheelFilter_.UpdateRailsMode(webEvent);
2504 if (renderWidgetHostView_->render_widget_host_->delegate() && 2512 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) {
2505 renderWidgetHostView_->render_widget_host_->delegate()
2506 ->GetInputEventRouter()) {
2507 renderWidgetHostView_->render_widget_host_->delegate() 2513 renderWidgetHostView_->render_widget_host_->delegate()
2508 ->GetInputEventRouter() 2514 ->GetInputEventRouter()
2509 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent); 2515 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent);
2510 } else { 2516 } else {
2511 renderWidgetHostView_->render_widget_host_->ForwardWheelEvent(webEvent); 2517 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent);
2512 } 2518 }
2513 } 2519 }
2514 } 2520 }
2515 2521
2516 // Called repeatedly during a pinch gesture, with incremental change values. 2522 // Called repeatedly during a pinch gesture, with incremental change values.
2517 - (void)magnifyWithEvent:(NSEvent*)event { 2523 - (void)magnifyWithEvent:(NSEvent*)event {
2518 if (!renderWidgetHostView_->render_widget_host_) 2524 if (!renderWidgetHostView_->render_widget_host_)
2519 return; 2525 return;
2520 2526
2521 // If, due to nesting of multiple gestures (e.g, from multiple touch 2527 // If, due to nesting of multiple gestures (e.g, from multiple touch
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
3444 3450
3445 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3451 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3446 // regions that are not draggable. (See ControlRegionView in 3452 // regions that are not draggable. (See ControlRegionView in
3447 // native_app_window_cocoa.mm). This requires the render host view to be 3453 // native_app_window_cocoa.mm). This requires the render host view to be
3448 // draggable by default. 3454 // draggable by default.
3449 - (BOOL)mouseDownCanMoveWindow { 3455 - (BOOL)mouseDownCanMoveWindow {
3450 return YES; 3456 return YES;
3451 } 3457 }
3452 3458
3453 @end 3459 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698